home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / hello-1.3 / hello-1
Tape Archive  |  1993-05-23  |  300.0 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: Tape Archive (archive/tar).

You can browse this item here: hello-1

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Tape Archive (archive/tar) magic Supported
100% file tar archive default
99% file tar archive (V7), file hello-1.3/hello.c, mode 666 , uid 23033 , gid 12 , size 12127 , seconds 5377544261 default
98% file data default
100% siegfried x-fmt/265 Tape Archive Format default
100% lsar Tar default
100% gt2 Kopftext: 'hello-1.3/hello.c' default (weak)
100% disktype Pre-POSIX tar archive default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 68 65 6c 6c 6f 2d 31 2e | 33 2f 68 65 6c 6c 6f 2e |hello-1.|3/hello.|
|00000010| 63 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |c.......|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000050| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000060| 00 00 00 00 20 20 20 36 | 36 36 20 00 20 32 33 30 |.... 6|66 . 230|
|00000070| 33 33 20 00 20 20 20 20 | 31 32 20 00 20 20 20 20 |33 . |12 . |
|00000080| 20 20 31 32 31 32 37 20 | 20 35 33 37 37 35 34 34 | 12127 | 5377544|
|00000090| 32 36 31 20 20 20 37 30 | 36 30 00 20 00 00 00 00 |261 70|60. ....|
|000000a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000100| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000110| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000120| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000130| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000140| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000150| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000160| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000170| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000180| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000190| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000200| 2f 2a 20 68 65 6c 6c 6f | 20 2d 2d 20 70 72 69 6e |/* hello| -- prin|
|00000210| 74 20 61 20 67 72 65 65 | 74 69 6e 67 20 6d 65 73 |t a gree|ting mes|
|00000220| 73 61 67 65 20 61 6e 64 | 20 65 78 69 74 2e 0a 20 |sage and| exit.. |
|00000230| 20 20 43 6f 70 79 72 69 | 67 68 74 20 28 43 29 20 | Copyri|ght (C) |
|00000240| 31 39 39 32 20 46 72 65 | 65 20 53 6f 66 74 77 61 |1992 Fre|e Softwa|
|00000250| 72 65 20 46 6f 75 6e 64 | 61 74 69 6f 6e 2c 20 49 |re Found|ation, I|
|00000260| 6e 63 2e 0a 0a 20 20 20 | 54 68 69 73 20 70 72 6f |nc... |This pro|
|00000270| 67 72 61 6d 20 69 73 20 | 66 72 65 65 20 73 6f 66 |gram is |free sof|
|00000280| 74 77 61 72 65 3b 20 79 | 6f 75 20 63 61 6e 20 72 |tware; y|ou can r|
|00000290| 65 64 69 73 74 72 69 62 | 75 74 65 20 69 74 20 61 |edistrib|ute it a|
|000002a0| 6e 64 2f 6f 72 20 6d 6f | 64 69 66 79 0a 20 20 20 |nd/or mo|dify. |
|000002b0| 69 74 20 75 6e 64 65 72 | 20 74 68 65 20 74 65 72 |it under| the ter|
|000002c0| 6d 73 20 6f 66 20 74 68 | 65 20 47 4e 55 20 47 65 |ms of th|e GNU Ge|
|000002d0| 6e 65 72 61 6c 20 50 75 | 62 6c 69 63 20 4c 69 63 |neral Pu|blic Lic|
|000002e0| 65 6e 73 65 20 61 73 20 | 70 75 62 6c 69 73 68 65 |ense as |publishe|
|000002f0| 64 20 62 79 0a 20 20 20 | 74 68 65 20 46 72 65 65 |d by. |the Free|
|00000300| 20 53 6f 66 74 77 61 72 | 65 20 46 6f 75 6e 64 61 | Softwar|e Founda|
|00000310| 74 69 6f 6e 3b 20 65 69 | 74 68 65 72 20 76 65 72 |tion; ei|ther ver|
|00000320| 73 69 6f 6e 20 32 2c 20 | 6f 72 20 28 61 74 20 79 |sion 2, |or (at y|
|00000330| 6f 75 72 20 6f 70 74 69 | 6f 6e 29 0a 20 20 20 61 |our opti|on). a|
|00000340| 6e 79 20 6c 61 74 65 72 | 20 76 65 72 73 69 6f 6e |ny later| version|
|00000350| 2e 0a 0a 20 20 20 54 68 | 69 73 20 70 72 6f 67 72 |... Th|is progr|
|00000360| 61 6d 20 69 73 20 64 69 | 73 74 72 69 62 75 74 65 |am is di|stribute|
|00000370| 64 20 69 6e 20 74 68 65 | 20 68 6f 70 65 20 74 68 |d in the| hope th|
|00000380| 61 74 20 69 74 20 77 69 | 6c 6c 20 62 65 20 75 73 |at it wi|ll be us|
|00000390| 65 66 75 6c 2c 0a 20 20 | 20 62 75 74 20 57 49 54 |eful,. | but WIT|
|000003a0| 48 4f 55 54 20 41 4e 59 | 20 57 41 52 52 41 4e 54 |HOUT ANY| WARRANT|
|000003b0| 59 3b 20 77 69 74 68 6f | 75 74 20 65 76 65 6e 20 |Y; witho|ut even |
|000003c0| 74 68 65 20 69 6d 70 6c | 69 65 64 20 77 61 72 72 |the impl|ied warr|
|000003d0| 61 6e 74 79 20 6f 66 0a | 20 20 20 4d 45 52 43 48 |anty of.| MERCH|
|000003e0| 41 4e 54 41 42 49 4c 49 | 54 59 20 6f 72 20 46 49 |ANTABILI|TY or FI|
|000003f0| 54 4e 45 53 53 20 46 4f | 52 20 41 20 50 41 52 54 |TNESS FO|R A PART|
|00000400| 49 43 55 4c 41 52 20 50 | 55 52 50 4f 53 45 2e 20 |ICULAR P|URPOSE. |
|00000410| 20 53 65 65 20 74 68 65 | 0a 20 20 20 47 4e 55 20 | See the|. GNU |
|00000420| 47 65 6e 65 72 61 6c 20 | 50 75 62 6c 69 63 20 4c |General |Public L|
|00000430| 69 63 65 6e 73 65 20 66 | 6f 72 20 6d 6f 72 65 20 |icense f|or more |
|00000440| 64 65 74 61 69 6c 73 2e | 0a 0a 20 20 20 59 6f 75 |details.|.. You|
|00000450| 20 73 68 6f 75 6c 64 20 | 68 61 76 65 20 72 65 63 | should |have rec|
|00000460| 65 69 76 65 64 20 61 20 | 63 6f 70 79 20 6f 66 20 |eived a |copy of |
|00000470| 74 68 65 20 47 4e 55 20 | 47 65 6e 65 72 61 6c 20 |the GNU |General |
|00000480| 50 75 62 6c 69 63 20 4c | 69 63 65 6e 73 65 0a 20 |Public L|icense. |
|00000490| 20 20 61 6c 6f 6e 67 20 | 77 69 74 68 20 74 68 69 | along |with thi|
|000004a0| 73 20 70 72 6f 67 72 61 | 6d 3b 20 69 66 20 6e 6f |s progra|m; if no|
|000004b0| 74 2c 20 77 72 69 74 65 | 20 74 6f 20 74 68 65 20 |t, write| to the |
|000004c0| 46 72 65 65 20 53 6f 66 | 74 77 61 72 65 0a 20 20 |Free Sof|tware. |
|000004d0| 20 46 6f 75 6e 64 61 74 | 69 6f 6e 2c 20 49 6e 63 | Foundat|ion, Inc|
|000004e0| 2e 2c 20 36 37 35 20 4d | 61 73 73 20 41 76 65 2c |., 675 M|ass Ave,|
|000004f0| 20 43 61 6d 62 72 69 64 | 67 65 2c 20 4d 41 20 30 | Cambrid|ge, MA 0|
|00000500| 32 31 33 39 2c 20 55 53 | 41 2e 20 20 2a 2f 0a 0a |2139, US|A. */..|
|00000510| 2f 2a 20 41 49 58 20 72 | 65 71 75 69 72 65 73 20 |/* AIX r|equires |
|00000520| 74 68 69 73 20 74 6f 20 | 62 65 20 74 68 65 20 66 |this to |be the f|
|00000530| 69 72 73 74 20 74 68 69 | 6e 67 20 69 6e 20 74 68 |irst thi|ng in th|
|00000540| 65 20 66 69 6c 65 2e 20 | 20 2a 2f 0a 23 69 66 20 |e file. | */.#if |
|00000550| 64 65 66 69 6e 65 64 20 | 28 5f 41 49 58 29 20 26 |defined |(_AIX) &|
|00000560| 26 20 21 64 65 66 69 6e | 65 64 20 28 5f 5f 47 4e |& !defin|ed (__GN|
|00000570| 55 43 5f 5f 29 0a 20 23 | 70 72 61 67 6d 61 20 61 |UC__). #|pragma a|
|00000580| 6c 6c 6f 63 61 0a 23 65 | 6e 64 69 66 0a 0a 23 69 |lloca.#e|ndif..#i|
|00000590| 6e 63 6c 75 64 65 20 3c | 73 74 64 69 6f 2e 68 3e |nclude <|stdio.h>|
|000005a0| 0a 23 69 6e 63 6c 75 64 | 65 20 3c 73 79 73 2f 74 |.#includ|e <sys/t|
|000005b0| 79 70 65 73 2e 68 3e 0a | 23 69 6e 63 6c 75 64 65 |ypes.h>.|#include|
|000005c0| 20 3c 73 79 73 2f 73 74 | 61 74 2e 68 3e 0a 23 69 | <sys/st|at.h>.#i|
|000005d0| 6e 63 6c 75 64 65 20 3c | 70 77 64 2e 68 3e 0a 23 |nclude <|pwd.h>.#|
|000005e0| 69 6e 63 6c 75 64 65 20 | 3c 65 72 72 6e 6f 2e 68 |include |<errno.h|
|000005f0| 3e 0a 23 69 6e 63 6c 75 | 64 65 20 22 67 65 74 6f |>.#inclu|de "geto|
|00000600| 70 74 2e 68 22 0a 0a 23 | 69 66 6e 64 65 66 20 65 |pt.h"..#|ifndef e|
|00000610| 72 72 6e 6f 0a 65 78 74 | 65 72 6e 20 69 6e 74 20 |rrno.ext|ern int |
|00000620| 65 72 72 6e 6f 3b 0a 23 | 65 6e 64 69 66 0a 0a 23 |errno;.#|endif..#|
|00000630| 69 66 64 65 66 09 53 54 | 44 43 5f 48 45 41 44 45 |ifdef.ST|DC_HEADE|
|00000640| 52 53 0a 23 69 6e 63 6c | 75 64 65 20 3c 73 74 64 |RS.#incl|ude <std|
|00000650| 6c 69 62 2e 68 3e 0a 23 | 65 6c 73 65 09 2f 2a 20 |lib.h>.#|else./* |
|00000660| 4e 6f 74 20 53 54 44 43 | 5f 48 45 41 44 45 52 53 |Not STDC|_HEADERS|
|00000670| 20 2a 2f 0a 65 78 74 65 | 72 6e 20 76 6f 69 64 20 | */.exte|rn void |
|00000680| 65 78 69 74 20 28 29 3b | 0a 65 78 74 65 72 6e 20 |exit ();|.extern |
|00000690| 63 68 61 72 20 2a 6d 61 | 6c 6c 6f 63 20 28 29 3b |char *ma|lloc ();|
|000006a0| 0a 23 65 6e 64 69 66 09 | 2f 2a 20 53 54 44 43 5f |.#endif.|/* STDC_|
|000006b0| 48 45 41 44 45 52 53 20 | 2a 2f 0a 0a 23 69 66 64 |HEADERS |*/..#ifd|
|000006c0| 65 66 09 48 41 56 45 5f | 53 54 52 49 4e 47 5f 48 |ef.HAVE_|STRING_H|
|000006d0| 0a 23 69 6e 63 6c 75 64 | 65 20 3c 73 74 72 69 6e |.#includ|e <strin|
|000006e0| 67 2e 68 3e 0a 23 65 6c | 73 65 0a 23 69 6e 63 6c |g.h>.#el|se.#incl|
|000006f0| 75 64 65 20 3c 73 74 72 | 69 6e 67 73 2e 68 3e 0a |ude <str|ings.h>.|
|00000700| 23 65 6e 64 69 66 0a 0a | 23 69 66 64 65 66 20 48 |#endif..|#ifdef H|
|00000710| 41 56 45 5f 46 43 4e 54 | 4c 5f 48 0a 23 69 6e 63 |AVE_FCNT|L_H.#inc|
|00000720| 6c 75 64 65 20 3c 66 63 | 6e 74 6c 2e 68 3e 0a 23 |lude <fc|ntl.h>.#|
|00000730| 65 6e 64 69 66 0a 23 69 | 66 64 65 66 20 48 41 56 |endif.#i|fdef HAV|
|00000740| 45 5f 53 59 53 5f 46 49 | 4c 45 5f 48 0a 23 69 6e |E_SYS_FI|LE_H.#in|
|00000750| 63 6c 75 64 65 20 3c 73 | 79 73 2f 66 69 6c 65 2e |clude <s|ys/file.|
|00000760| 68 3e 0a 23 65 6e 64 69 | 66 0a 0a 23 69 66 64 65 |h>.#endi|f..#ifde|
|00000770| 66 09 5f 5f 47 4e 55 43 | 5f 5f 0a 23 75 6e 64 65 |f.__GNUC|__.#unde|
|00000780| 66 09 61 6c 6c 6f 63 61 | 0a 23 64 65 66 69 6e 65 |f.alloca|.#define|
|00000790| 09 61 6c 6c 6f 63 61 28 | 6e 29 09 5f 5f 62 75 69 |.alloca(|n).__bui|
|000007a0| 6c 74 69 6e 5f 61 6c 6c | 6f 63 61 20 28 6e 29 0a |ltin_all|oca (n).|
|000007b0| 23 65 6c 73 65 09 2f 2a | 20 4e 6f 74 20 47 43 43 |#else./*| Not GCC|
|000007c0| 2e 20 20 2a 2f 0a 23 69 | 66 64 65 66 09 48 41 56 |. */.#i|fdef.HAV|
|000007d0| 45 5f 41 4c 4c 4f 43 41 | 5f 48 0a 23 69 6e 63 6c |E_ALLOCA|_H.#incl|
|000007e0| 75 64 65 20 3c 61 6c 6c | 6f 63 61 2e 68 3e 0a 23 |ude <all|oca.h>.#|
|000007f0| 65 6c 73 65 09 2f 2a 20 | 4e 6f 74 20 48 41 56 45 |else./* |Not HAVE|
|00000800| 5f 41 4c 4c 4f 43 41 5f | 48 2e 20 20 2a 2f 0a 23 |_ALLOCA_|H. */.#|
|00000810| 69 66 6e 64 65 66 09 5f | 41 49 58 0a 65 78 74 65 |ifndef._|AIX.exte|
|00000820| 72 6e 20 63 68 61 72 20 | 2a 61 6c 6c 6f 63 61 20 |rn char |*alloca |
|00000830| 28 29 3b 0a 23 65 6e 64 | 69 66 09 2f 2a 20 4e 6f |();.#end|if./* No|
|00000840| 74 20 41 49 58 2e 20 20 | 2a 2f 0a 23 65 6e 64 69 |t AIX. |*/.#endi|
|00000850| 66 09 2f 2a 20 48 41 56 | 45 5f 41 4c 4c 4f 43 41 |f./* HAV|E_ALLOCA|
|00000860| 5f 48 2e 20 20 2a 2f 0a | 23 65 6e 64 69 66 09 2f |_H. */.|#endif./|
|00000870| 2a 20 47 43 43 2e 20 20 | 2a 2f 0a 0a 0a 23 64 65 |* GCC. |*/...#de|
|00000880| 66 69 6e 65 20 74 68 65 | 20 28 31 29 0a 0a 73 74 |fine the| (1)..st|
|00000890| 72 75 63 74 20 6f 70 74 | 69 6f 6e 20 6c 6f 6e 67 |ruct opt|ion long|
|000008a0| 6f 70 74 73 5b 5d 20 3d | 0a 20 20 7b 0a 20 20 20 |opts[] =|. {. |
|000008b0| 20 7b 20 22 76 65 72 73 | 69 6f 6e 22 2c 20 30 2c | { "vers|ion", 0,|
|000008c0| 20 30 2c 20 27 76 27 20 | 7d 2c 0a 20 20 20 20 7b | 0, 'v' |},. {|
|000008d0| 20 22 68 65 6c 70 22 2c | 20 30 2c 20 30 2c 20 27 | "help",| 0, 0, '|
|000008e0| 68 27 20 7d 2c 0a 23 64 | 65 66 69 6e 65 20 6c 69 |h' },.#d|efine li|
|000008f0| 76 65 73 0a 20 20 20 20 | 7b 20 22 74 72 61 64 69 |ves. |{ "tradi|
|00000900| 74 69 6f 6e 61 6c 22 2c | 20 30 2c 20 30 2c 20 27 |tional",| 0, 0, '|
|00000910| 74 27 20 7d 2c 0a 20 20 | 20 20 7b 20 22 6d 61 69 |t' },. | { "mai|
|00000920| 6c 22 2c 20 30 2c 20 30 | 2c 20 27 6d 27 20 7d 2c |l", 0, 0|, 'm' },|
|00000930| 0a 20 20 20 20 7b 20 30 | 2c 20 30 2c 20 30 2c 20 |. { 0|, 0, 0, |
|00000940| 30 20 7d 0a 20 20 7d 3b | 0a 0a 65 78 74 65 72 6e |0 }. };|..extern|
|00000950| 20 63 68 61 72 20 76 65 | 72 73 69 6f 6e 5b 5d 3b | char ve|rsion[];|
|00000960| 0a 0a 63 68 61 72 20 75 | 73 61 67 65 5b 5d 20 3d |..char u|sage[] =|
|00000970| 20 22 55 73 61 67 65 3a | 20 25 73 20 5b 2d 68 74 | "Usage:| %s [-ht|
|00000980| 76 6d 5d 20 5b 2d 2d 68 | 65 6c 70 5d 20 5b 2d 2d |vm] [--h|elp] [--|
|00000990| 74 72 61 64 69 74 69 6f | 6e 61 6c 5d 20 5b 2d 2d |traditio|nal] [--|
|000009a0| 76 65 72 73 69 6f 6e 5d | 20 5b 2d 2d 6d 61 69 6c |version]| [--mail|
|000009b0| 5d 5c 6e 22 3b 0a 0a 73 | 74 61 74 69 63 20 63 68 |]\n";..s|tatic ch|
|000009c0| 61 72 20 2a 70 72 6f 67 | 6e 61 6d 65 3b 0a 0a 69 |ar *prog|name;..i|
|000009d0| 6e 74 0a 6d 61 69 6e 20 | 28 61 72 67 63 2c 20 61 |nt.main |(argc, a|
|000009e0| 72 67 76 29 0a 20 20 20 | 20 20 69 6e 74 20 61 72 |rgv). | int ar|
|000009f0| 67 63 3b 0a 20 20 20 20 | 20 63 68 61 72 20 2a 61 |gc;. | char *a|
|00000a00| 72 67 76 5b 5d 3b 0a 7b | 0a 20 20 69 6e 74 20 6f |rgv[];.{|. int o|
|00000a10| 70 74 63 3b 0a 20 20 69 | 6e 74 20 68 20 3d 20 30 |ptc;. i|nt h = 0|
|00000a20| 2c 20 76 20 3d 20 30 2c | 20 74 20 3d 20 30 2c 20 |, v = 0,| t = 0, |
|00000a30| 6d 20 3d 20 30 2c 20 6c | 6f 73 65 20 3d 20 30 2c |m = 0, l|ose = 0,|
|00000a40| 20 7a 20 3d 20 30 3b 0a | 0a 20 20 70 72 6f 67 6e | z = 0;.|. progn|
|00000a50| 61 6d 65 20 3d 20 61 72 | 67 76 5b 30 5d 3b 0a 0a |ame = ar|gv[0];..|
|00000a60| 23 64 65 66 69 6e 65 20 | 6b 69 6e 67 0a 20 20 77 |#define |king. w|
|00000a70| 68 69 6c 65 20 28 28 6f | 70 74 63 20 3d 20 67 65 |hile ((o|ptc = ge|
|00000a80| 74 6f 70 74 5f 6c 6f 6e | 67 20 28 61 72 67 63 2c |topt_lon|g (argc,|
|00000a90| 20 61 72 67 76 2c 20 22 | 68 74 76 6d 22 2c 20 6c | argv, "|htvm", l|
|00000aa0| 6f 6e 67 6f 70 74 73 2c | 20 28 69 6e 74 20 2a 29 |ongopts,| (int *)|
|00000ab0| 20 30 29 29 20 21 3d 20 | 45 4f 46 29 0a 20 20 20 | 0)) != |EOF). |
|00000ac0| 20 7b 0a 20 20 20 20 20 | 20 73 77 69 74 63 68 20 | {. | switch |
|00000ad0| 28 6f 70 74 63 29 0a 09 | 7b 0a 09 63 61 73 65 20 |(optc)..|{..case |
|00000ae0| 27 76 27 3a 0a 09 20 20 | 76 20 3d 20 31 3b 0a 09 |'v':.. |v = 1;..|
|00000af0| 20 20 62 72 65 61 6b 3b | 0a 09 63 61 73 65 20 27 | break;|..case '|
|00000b00| 68 27 3a 0a 09 20 20 68 | 20 3d 20 31 3b 0a 09 20 |h':.. h| = 1;.. |
|00000b10| 20 62 72 65 61 6b 3b 0a | 09 63 61 73 65 20 27 6d | break;.|.case 'm|
|00000b20| 27 3a 0a 09 20 20 6d 20 | 3d 20 31 3b 0a 09 20 20 |':.. m |= 1;.. |
|00000b30| 62 72 65 61 6b 3b 0a 09 | 63 61 73 65 20 27 74 27 |break;..|case 't'|
|00000b40| 3a 0a 09 20 20 74 20 3d | 20 31 3b 0a 09 20 20 62 |:.. t =| 1;.. b|
|00000b50| 72 65 61 6b 3b 0a 09 64 | 65 66 61 75 6c 74 3a 0a |reak;..d|efault:.|
|00000b60| 09 20 20 6c 6f 73 65 20 | 3d 20 31 3b 0a 09 20 20 |. lose |= 1;.. |
|00000b70| 62 72 65 61 6b 3b 0a 09 | 7d 0a 20 20 20 20 7d 0a |break;..|}. }.|
|00000b80| 0a 20 20 69 66 20 28 6f | 70 74 69 6e 64 20 3d 3d |. if (o|ptind ==|
|00000b90| 20 61 72 67 63 20 2d 20 | 31 20 26 26 20 21 73 74 | argc - |1 && !st|
|00000ba0| 72 63 6d 70 20 28 61 72 | 67 76 5b 6f 70 74 69 6e |rcmp (ar|gv[optin|
|00000bb0| 64 5d 2c 20 22 73 61 69 | 6c 6f 72 22 29 29 0a 20 |d], "sai|lor")). |
|00000bc0| 20 20 20 7a 20 3d 20 31 | 3b 0a 20 20 65 6c 73 65 | z = 1|;. else|
|00000bd0| 20 69 66 20 28 6c 6f 73 | 65 20 7c 7c 20 6f 70 74 | if (los|e || opt|
|00000be0| 69 6e 64 20 3c 20 61 72 | 67 63 29 0a 20 20 20 20 |ind < ar|gc). |
|00000bf0| 7b 0a 20 20 20 20 20 20 | 2f 2a 20 50 72 69 6e 74 |{. |/* Print|
|00000c00| 20 65 72 72 6f 72 20 6d | 65 73 73 61 67 65 20 61 | error m|essage a|
|00000c10| 6e 64 20 65 78 69 74 2e | 20 20 2a 2f 0a 20 20 20 |nd exit.| */. |
|00000c20| 20 20 20 66 70 72 69 6e | 74 66 20 28 73 74 64 65 | fprin|tf (stde|
|00000c30| 72 72 2c 20 75 73 61 67 | 65 2c 20 70 72 6f 67 6e |rr, usag|e, progn|
|00000c40| 61 6d 65 29 3b 0a 20 20 | 20 20 20 20 65 78 69 74 |ame);. | exit|
|00000c50| 20 28 31 29 3b 0a 20 20 | 20 20 7d 0a 0a 20 20 69 | (1);. | }.. i|
|00000c60| 66 20 28 76 29 0a 20 20 | 20 20 7b 0a 20 20 20 20 |f (v). | {. |
|00000c70| 20 20 2f 2a 20 50 72 69 | 6e 74 20 76 65 72 73 69 | /* Pri|nt versi|
|00000c80| 6f 6e 20 6e 75 6d 62 65 | 72 2e 20 20 2a 2f 0a 20 |on numbe|r. */. |
|00000c90| 20 20 20 20 20 66 70 72 | 69 6e 74 66 20 28 73 74 | fpr|intf (st|
|00000ca0| 64 65 72 72 2c 20 22 25 | 73 5c 6e 22 2c 20 76 65 |derr, "%|s\n", ve|
|00000cb0| 72 73 69 6f 6e 29 3b 0a | 20 20 20 20 20 20 69 66 |rsion);.| if|
|00000cc0| 20 28 21 20 68 29 0a 09 | 65 78 69 74 20 28 30 29 | (! h)..|exit (0)|
|00000cd0| 3b 0a 20 20 20 20 7d 0a | 0a 20 20 69 66 20 28 68 |;. }.|. if (h|
|00000ce0| 29 0a 20 20 20 20 7b 0a | 20 20 20 20 20 20 2f 2a |). {.| /*|
|00000cf0| 20 50 72 69 6e 74 20 68 | 65 6c 70 20 69 6e 66 6f | Print h|elp info|
|00000d00| 20 61 6e 64 20 65 78 69 | 74 2e 20 20 2a 2f 0a 20 | and exi|t. */. |
|00000d10| 20 20 20 20 20 66 70 75 | 74 73 20 28 22 54 68 69 | fpu|ts ("Thi|
|00000d20| 73 20 69 73 20 47 4e 55 | 20 48 65 6c 6c 6f 2c 20 |s is GNU| Hello, |
|00000d30| 54 48 45 20 67 72 65 65 | 74 69 6e 67 20 70 72 69 |THE gree|ting pri|
|00000d40| 6e 74 69 6e 67 20 70 72 | 6f 67 72 61 6d 2e 5c 6e |nting pr|ogram.\n|
|00000d50| 22 2c 0a 09 20 20 20 20 | 20 73 74 64 65 72 72 29 |",.. | stderr)|
|00000d60| 3b 0a 20 20 20 20 20 20 | 66 70 72 69 6e 74 66 20 |;. |fprintf |
|00000d70| 28 73 74 64 65 72 72 2c | 20 75 73 61 67 65 2c 20 |(stderr,| usage, |
|00000d80| 70 72 6f 67 6e 61 6d 65 | 29 3b 0a 20 20 20 20 20 |progname|);. |
|00000d90| 20 66 70 75 74 73 20 28 | 22 20 20 2d 68 2c 20 2d | fputs (|" -h, -|
|00000da0| 2d 68 65 6c 70 5c 74 5c | 74 5c 74 50 72 69 6e 74 |-help\t\|t\tPrint|
|00000db0| 20 61 20 73 75 6d 6d 61 | 72 79 20 6f 66 20 74 68 | a summa|ry of th|
|00000dc0| 65 20 6f 70 74 69 6f 6e | 73 5c 6e 22 2c 20 73 74 |e option|s\n", st|
|00000dd0| 64 65 72 72 29 3b 0a 20 | 20 20 20 20 20 66 70 75 |derr);. | fpu|
|00000de0| 74 73 20 28 22 20 20 2d | 74 2c 20 2d 2d 74 72 61 |ts (" -|t, --tra|
|00000df0| 64 69 74 69 6f 6e 61 6c | 5c 74 5c 74 55 73 65 20 |ditional|\t\tUse |
|00000e00| 74 72 61 64 69 74 69 6f | 6e 61 6c 20 67 72 65 65 |traditio|nal gree|
|00000e10| 74 69 6e 67 20 66 6f 72 | 6d 61 74 5c 6e 22 2c 0a |ting for|mat\n",.|
|00000e20| 09 20 20 20 20 20 0a 09 | 20 20 20 20 20 73 74 64 |. ..| std|
|00000e30| 65 72 72 29 3b 0a 20 20 | 20 20 20 20 66 70 75 74 |err);. | fput|
|00000e40| 73 20 28 22 20 20 2d 76 | 2c 20 2d 2d 76 65 72 73 |s (" -v|, --vers|
|00000e50| 69 6f 6e 5c 74 5c 74 5c | 74 50 72 69 6e 74 20 74 |ion\t\t\|tPrint t|
|00000e60| 68 65 20 76 65 72 73 69 | 6f 6e 20 6e 75 6d 62 65 |he versi|on numbe|
|00000e70| 72 5c 6e 22 2c 20 73 74 | 64 65 72 72 29 3b 0a 20 |r\n", st|derr);. |
|00000e80| 20 20 20 20 20 66 70 75 | 74 73 20 28 22 20 20 2d | fpu|ts (" -|
|00000e90| 6d 2c 20 2d 2d 6d 61 69 | 6c 5c 74 5c 74 5c 74 50 |m, --mai|l\t\t\tP|
|00000ea0| 72 69 6e 74 20 79 6f 75 | 72 20 6d 61 69 6c 5c 6e |rint you|r mail\n|
|00000eb0| 22 2c 20 73 74 64 65 72 | 72 29 3b 0a 20 20 20 20 |", stder|r);. |
|00000ec0| 20 20 65 78 69 74 20 28 | 30 29 3b 0a 20 20 20 20 | exit (|0);. |
|00000ed0| 7d 0a 0a 20 20 2f 2a 20 | 50 72 69 6e 74 20 67 72 |}.. /* |Print gr|
|00000ee0| 65 65 74 69 6e 67 20 6d | 65 73 73 61 67 65 20 61 |eeting m|essage a|
|00000ef0| 6e 64 20 65 78 69 74 2e | 20 20 2a 2f 0a 0a 20 20 |nd exit.| */.. |
|00000f00| 69 66 20 28 6d 29 0a 20 | 20 20 20 7b 0a 20 20 20 |if (m). | {. |
|00000f10| 20 20 20 63 68 61 72 20 | 2a 6d 61 69 6c 6e 61 6d | char |*mailnam|
|00000f20| 65 2c 20 2a 62 75 66 2c | 20 2a 67 65 74 65 6e 76 |e, *buf,| *getenv|
|00000f30| 20 28 29 3b 0a 20 20 20 | 20 20 20 69 6e 74 20 6d | ();. | int m|
|00000f40| 61 69 6c 66 64 2c 20 63 | 63 3b 0a 20 20 20 20 20 |ailfd, c|c;. |
|00000f50| 20 73 74 72 75 63 74 20 | 73 74 61 74 20 73 74 3b | struct |stat st;|
|00000f60| 0a 20 20 20 20 20 20 0a | 20 20 20 20 20 20 6d 61 |. .| ma|
|00000f70| 69 6c 6e 61 6d 65 20 3d | 20 67 65 74 65 6e 76 20 |ilname =| getenv |
|00000f80| 28 22 4d 41 49 4c 22 29 | 3b 0a 20 20 20 20 20 20 |("MAIL")|;. |
|00000f90| 69 66 20 28 21 6d 61 69 | 6c 6e 61 6d 65 29 0a 09 |if (!mai|lname)..|
|00000fa0| 7b 0a 09 20 20 73 74 61 | 74 69 63 20 63 68 61 72 |{.. sta|tic char|
|00000fb0| 20 2a 64 69 72 73 5b 5d | 20 3d 0a 09 20 20 20 20 | *dirs[]| =.. |
|00000fc0| 7b 0a 09 20 20 20 20 20 | 20 22 2f 75 73 72 2f 73 |{.. | "/usr/s|
|00000fd0| 70 6f 6f 6c 2f 6d 61 69 | 6c 22 2c 0a 09 20 20 20 |pool/mai|l",.. |
|00000fe0| 20 20 20 22 2f 75 73 72 | 2f 6d 61 69 6c 22 2c 0a | "/usr|/mail",.|
|00000ff0| 09 20 20 20 20 20 20 30 | 0a 09 20 20 20 20 7d 3b |. 0|.. };|
|00001000| 0a 09 20 20 63 68 61 72 | 20 2a 2a 64 3b 0a 09 20 |.. char| **d;.. |
|00001010| 20 75 6e 73 69 67 6e 65 | 64 20 69 6e 74 20 64 69 | unsigne|d int di|
|00001020| 72 6c 65 6e 2c 20 75 73 | 65 72 6c 65 6e 3b 0a 0a |rlen, us|erlen;..|
|00001030| 09 20 20 63 68 61 72 20 | 2a 75 73 65 72 20 3d 20 |. char |*user = |
|00001040| 67 65 74 65 6e 76 20 28 | 22 55 53 45 52 22 29 3b |getenv (|"USER");|
|00001050| 0a 0a 09 20 20 69 66 20 | 28 21 20 75 73 65 72 29 |... if |(! user)|
|00001060| 0a 09 20 20 20 20 7b 0a | 09 20 20 20 20 20 20 73 |.. {.|. s|
|00001070| 74 72 75 63 74 20 70 61 | 73 73 77 64 20 2a 70 77 |truct pa|sswd *pw|
|00001080| 64 20 3d 20 67 65 74 70 | 77 75 69 64 20 28 67 65 |d = getp|wuid (ge|
|00001090| 74 75 69 64 20 28 29 29 | 3b 0a 09 20 20 20 20 20 |tuid ())|;.. |
|000010a0| 20 69 66 20 28 21 20 70 | 77 64 29 0a 09 09 7b 0a | if (! p|wd)...{.|
|000010b0| 09 09 20 20 66 70 72 69 | 6e 74 66 20 28 73 74 64 |.. fpri|ntf (std|
|000010c0| 65 72 72 2c 20 22 25 73 | 3a 20 57 68 6f 20 61 72 |err, "%s|: Who ar|
|000010d0| 65 20 79 6f 75 3f 5c 6e | 22 2c 20 70 72 6f 67 6e |e you?\n|", progn|
|000010e0| 61 6d 65 29 3b 0a 09 09 | 20 20 65 78 69 74 20 28 |ame);...| exit (|
|000010f0| 31 29 3b 0a 09 09 7d 0a | 09 20 20 20 20 20 20 75 |1);...}.|. u|
|00001100| 73 65 72 20 3d 20 70 77 | 64 2d 3e 70 77 5f 6e 61 |ser = pw|d->pw_na|
|00001110| 6d 65 3b 0a 09 20 20 20 | 20 7d 0a 09 20 20 0a 09 |me;.. | }.. ..|
|00001120| 20 20 64 69 72 6c 65 6e | 20 3d 20 30 3b 0a 09 20 | dirlen| = 0;.. |
|00001130| 20 66 6f 72 20 28 64 20 | 3d 20 64 69 72 73 3b 20 | for (d |= dirs; |
|00001140| 2a 64 20 21 3d 20 30 3b | 20 2b 2b 64 29 0a 09 20 |*d != 0;| ++d).. |
|00001150| 20 20 20 7b 0a 09 20 20 | 20 20 20 20 75 6e 73 69 | {.. | unsi|
|00001160| 67 6e 65 64 20 69 6e 74 | 20 6c 65 6e 20 3d 20 73 |gned int| len = s|
|00001170| 74 72 6c 65 6e 20 28 2a | 64 29 3b 0a 09 20 20 20 |trlen (*|d);.. |
|00001180| 20 20 20 69 66 20 28 6c | 65 6e 20 3e 20 64 69 72 | if (l|en > dir|
|00001190| 6c 65 6e 29 0a 09 09 64 | 69 72 6c 65 6e 20 3d 20 |len)...d|irlen = |
|000011a0| 6c 65 6e 3b 0a 09 20 20 | 20 20 7d 0a 0a 09 20 20 |len;.. | }... |
|000011b0| 75 73 65 72 6c 65 6e 20 | 3d 20 73 74 72 6c 65 6e |userlen |= strlen|
|000011c0| 20 28 75 73 65 72 29 3b | 0a 0a 09 20 20 6d 61 69 | (user);|... mai|
|000011d0| 6c 6e 61 6d 65 20 3d 20 | 61 6c 6c 6f 63 61 20 28 |lname = |alloca (|
|000011e0| 64 69 72 6c 65 6e 20 2b | 20 31 20 2b 20 75 73 65 |dirlen +| 1 + use|
|000011f0| 72 6c 65 6e 20 2b 20 31 | 29 3b 0a 0a 09 20 20 64 |rlen + 1|);... d|
|00001200| 20 3d 20 64 69 72 73 3b | 0a 09 20 20 64 6f 0a 09 | = dirs;|.. do..|
|00001210| 20 20 20 20 7b 0a 09 20 | 20 20 20 20 20 73 70 72 | {.. | spr|
|00001220| 69 6e 74 66 20 28 6d 61 | 69 6c 6e 61 6d 65 2c 20 |intf (ma|ilname, |
|00001230| 22 25 73 2f 25 73 22 2c | 20 2a 64 2c 20 75 73 65 |"%s/%s",| *d, use|
|00001240| 72 29 3b 0a 09 20 20 20 | 20 20 20 6d 61 69 6c 66 |r);.. | mailf|
|00001250| 64 20 3d 20 6f 70 65 6e | 20 28 6d 61 69 6c 6e 61 |d = open| (mailna|
|00001260| 6d 65 2c 20 4f 5f 52 44 | 4f 4e 4c 59 29 3b 0a 09 |me, O_RD|ONLY);..|
|00001270| 20 20 20 20 7d 20 77 68 | 69 6c 65 20 28 6d 61 69 | } wh|ile (mai|
|00001280| 6c 66 64 20 3d 3d 20 2d | 31 20 26 26 20 28 65 72 |lfd == -|1 && (er|
|00001290| 72 6e 6f 20 3d 3d 20 45 | 4e 4f 45 4e 54 20 7c 7c |rno == E|NOENT |||
|000012a0| 20 65 72 72 6e 6f 20 3d | 3d 20 45 4e 4f 54 44 49 | errno =|= ENOTDI|
|000012b0| 52 29 29 3b 0a 09 7d 0a | 20 20 20 20 20 20 65 6c |R));..}.| el|
|000012c0| 73 65 0a 09 6d 61 69 6c | 66 64 20 3d 20 6f 70 65 |se..mail|fd = ope|
|000012d0| 6e 20 28 6d 61 69 6c 6e | 61 6d 65 2c 20 4f 5f 52 |n (mailn|ame, O_R|
|000012e0| 44 4f 4e 4c 59 29 3b 0a | 0a 20 20 20 20 20 20 69 |DONLY);.|. i|
|000012f0| 66 20 28 6d 61 69 6c 66 | 64 20 3d 3d 20 2d 31 29 |f (mailf|d == -1)|
|00001300| 0a 09 7b 0a 09 20 20 70 | 65 72 72 6f 72 20 28 6d |..{.. p|error (m|
|00001310| 61 69 6c 6e 61 6d 65 29 | 3b 0a 09 20 20 65 78 69 |ailname)|;.. exi|
|00001320| 74 20 28 31 29 3b 0a 09 | 7d 0a 20 20 20 20 20 20 |t (1);..|}. |
|00001330| 69 66 20 28 66 73 74 61 | 74 20 28 6d 61 69 6c 66 |if (fsta|t (mailf|
|00001340| 64 2c 20 26 73 74 29 20 | 3d 3d 20 2d 31 29 0a 09 |d, &st) |== -1)..|
|00001350| 7b 0a 09 20 20 70 65 72 | 72 6f 72 20 28 6d 61 69 |{.. per|ror (mai|
|00001360| 6c 6e 61 6d 65 29 3b 0a | 09 20 20 65 78 69 74 20 |lname);.|. exit |
|00001370| 28 31 29 3b 0a 09 7d 0a | 20 20 20 20 20 20 62 75 |(1);..}.| bu|
|00001380| 66 20 3d 20 61 6c 6c 6f | 63 61 20 28 73 74 2e 73 |f = allo|ca (st.s|
|00001390| 74 5f 62 6c 6b 73 69 7a | 65 29 3b 0a 20 20 20 20 |t_blksiz|e);. |
|000013a0| 20 20 77 68 69 6c 65 20 | 74 68 65 20 6b 69 6e 67 | while |the king|
|000013b0| 20 6c 69 76 65 73 0a 09 | 7b 0a 09 20 20 63 63 20 | lives..|{.. cc |
|000013c0| 3d 20 72 65 61 64 20 28 | 6d 61 69 6c 66 64 2c 20 |= read (|mailfd, |
|000013d0| 62 75 66 2c 20 73 74 2e | 73 74 5f 62 6c 6b 73 69 |buf, st.|st_blksi|
|000013e0| 7a 65 29 3b 0a 09 20 20 | 0a 09 20 20 69 66 20 28 |ze);.. |.. if (|
|000013f0| 63 63 20 3d 3d 20 2d 31 | 29 0a 09 20 20 20 20 7b |cc == -1|).. {|
|00001400| 0a 09 20 20 20 20 20 20 | 70 65 72 72 6f 72 20 28 |.. |perror (|
|00001410| 6d 61 69 6c 6e 61 6d 65 | 29 3b 0a 09 20 20 20 20 |mailname|);.. |
|00001420| 20 20 65 78 69 74 20 28 | 31 29 3b 0a 09 20 20 20 | exit (|1);.. |
|00001430| 20 7d 0a 09 20 20 69 66 | 20 28 63 63 20 3d 3d 20 | }.. if| (cc == |
|00001440| 30 29 0a 09 20 20 20 20 | 62 72 65 61 6b 3b 0a 09 |0).. |break;..|
|00001450| 20 20 0a 09 20 20 63 63 | 20 3d 20 77 72 69 74 65 | .. cc| = write|
|00001460| 20 28 31 2c 20 62 75 66 | 2c 20 63 63 29 3b 0a 09 | (1, buf|, cc);..|
|00001470| 20 20 69 66 20 28 63 63 | 20 3d 3d 20 2d 31 29 0a | if (cc| == -1).|
|00001480| 09 20 20 20 20 7b 0a 09 | 20 20 20 20 20 20 70 65 |. {..| pe|
|00001490| 72 72 6f 72 20 28 6d 61 | 69 6c 6e 61 6d 65 29 3b |rror (ma|ilname);|
|000014a0| 0a 09 20 20 20 20 20 20 | 65 78 69 74 20 28 31 29 |.. |exit (1)|
|000014b0| 3b 0a 09 20 20 20 20 7d | 0a 09 7d 0a 20 20 20 20 |;.. }|..}. |
|000014c0| 7d 0a 20 20 65 6c 73 65 | 20 69 66 20 28 7a 29 0a |}. else| if (z).|
|000014d0| 20 20 20 20 70 75 74 73 | 20 28 22 4e 6f 74 68 69 | puts| ("Nothi|
|000014e0| 6e 67 20 68 61 70 70 65 | 6e 73 20 68 65 72 65 2e |ng happe|ns here.|
|000014f0| 22 29 3b 0a 20 20 65 6c | 73 65 0a 20 20 20 20 7b |");. el|se. {|
|00001500| 0a 20 20 20 20 20 20 69 | 66 20 28 74 29 0a 20 20 |. i|f (t). |
|00001510| 20 20 20 20 20 20 70 72 | 69 6e 74 66 20 28 22 68 | pr|intf ("h|
|00001520| 65 6c 6c 6f 2c 20 77 6f | 72 6c 64 5c 6e 22 29 3b |ello, wo|rld\n");|
|00001530| 0a 20 20 20 20 20 20 65 | 6c 73 65 0a 20 20 20 20 |. e|lse. |
|00001540| 20 20 20 20 70 75 74 73 | 20 28 22 48 65 6c 6c 6f | puts| ("Hello|
|00001550| 2c 20 77 6f 72 6c 64 21 | 22 29 3b 0a 20 20 20 20 |, world!|");. |
|00001560| 7d 0a 0a 20 20 65 78 69 | 74 20 28 30 29 3b 0a 7d |}.. exi|t (0);.}|
|00001570| 0a 0c 0a 2f 2a 20 55 73 | 65 64 20 62 79 20 61 6c |.../* Us|ed by al|
|00001580| 6c 6f 63 61 2e 63 2e 20 | 20 2a 2f 0a 0a 63 68 61 |loca.c. | */..cha|
|00001590| 72 20 2a 0a 78 6d 61 6c | 6c 6f 63 20 28 73 69 7a |r *.xmal|loc (siz|
|000015a0| 65 29 0a 20 20 20 20 20 | 75 6e 73 69 67 6e 65 64 |e). |unsigned|
|000015b0| 20 69 6e 74 20 73 69 7a | 65 3b 0a 7b 0a 20 20 63 | int siz|e;.{. c|
|000015c0| 68 61 72 20 2a 70 74 72 | 20 3d 20 6d 61 6c 6c 6f |har *ptr| = mallo|
|000015d0| 63 20 28 73 69 7a 65 29 | 3b 0a 20 20 69 66 20 28 |c (size)|;. if (|
|000015e0| 21 20 70 74 72 29 0a 20 | 20 20 20 7b 0a 20 20 20 |! ptr). | {. |
|000015f0| 20 20 20 66 70 72 69 6e | 74 66 20 28 73 74 64 65 | fprin|tf (stde|
|00001600| 72 72 2c 20 22 25 73 3a | 20 76 69 72 74 75 61 6c |rr, "%s:| virtual|
|00001610| 20 6d 65 6d 6f 72 79 20 | 65 78 68 61 75 73 74 65 | memory |exhauste|
|00001620| 64 5c 6e 22 2c 20 70 72 | 6f 67 6e 61 6d 65 29 3b |d\n", pr|ogname);|
|00001630| 0a 20 20 20 20 20 20 65 | 78 69 74 20 28 31 29 3b |. e|xit (1);|
|00001640| 0a 20 20 20 20 7d 0a 20 | 20 72 65 74 75 72 6e 20 |. }. | return |
|00001650| 70 74 72 3b 0a 7d 0a 00 | 00 00 00 00 00 00 00 00 |ptr;.}..|........|
|00001660| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001670| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001680| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001690| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000016a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000016b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000016c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000016d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000016e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000016f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001700| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001710| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001720| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001730| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001740| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001750| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001760| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001770| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001780| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001790| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000017a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000017b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000017c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000017d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000017e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000017f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001800| 68 65 6c 6c 6f 2d 31 2e | 33 2f 76 65 72 73 69 6f |hello-1.|3/versio|
|00001810| 6e 2e 63 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |n.c.....|........|
|00001820| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001830| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001840| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001850| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001860| 00 00 00 00 20 20 20 36 | 36 36 20 00 20 32 33 30 |.... 6|66 . 230|
|00001870| 33 33 20 00 20 20 20 20 | 31 32 20 00 20 20 20 20 |33 . |12 . |
|00001880| 20 20 20 20 20 35 33 20 | 20 35 33 37 37 35 34 34 | 53 | 5377544|
|00001890| 33 31 36 20 20 20 37 33 | 35 36 00 20 00 00 00 00 |316 73|56. ....|
|000018a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000018b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000018c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000018d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000018e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000018f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001900| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001910| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001920| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001930| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001940| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001950| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001960| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001970| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001980| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001990| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000019a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000019b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000019c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000019d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000019e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000019f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001a00| 63 68 61 72 20 76 65 72 | 73 69 6f 6e 5b 5d 20 3d |char ver|sion[] =|
|00001a10| 20 22 47 4e 55 20 48 65 | 6c 6c 6f 2c 20 76 65 72 | "GNU He|llo, ver|
|00001a20| 73 69 6f 6e 20 31 2e 33 | 22 3b 0a 00 00 00 00 00 |sion 1.3|";......|
|00001a30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001a40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001a50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001a60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001a70| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001a80| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001a90| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001aa0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ab0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ac0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ad0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ae0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001af0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001b00| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001b10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001b20| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001b30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001b40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001b50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001b60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001b70| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001b80| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001b90| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ba0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001bb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001bc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001bd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001be0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001bf0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001c00| 68 65 6c 6c 6f 2d 31 2e | 33 2f 67 65 74 6f 70 74 |hello-1.|3/getopt|
|00001c10| 2e 63 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.c......|........|
|00001c20| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001c30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001c40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001c50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001c60| 00 00 00 00 20 20 20 36 | 36 36 20 00 20 31 32 32 |.... 6|66 . 122|
|00001c70| 34 31 20 00 20 20 20 20 | 20 31 20 00 20 20 20 20 |41 . | 1 . |
|00001c80| 20 20 35 30 36 31 34 20 | 20 35 33 37 32 35 33 34 | 50614 | 5372534|
|00001c90| 32 36 36 20 20 20 37 32 | 33 36 00 20 00 00 00 00 |266 72|36. ....|
|00001ca0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001cb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001cc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001cd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ce0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001cf0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001d00| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001d10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001d20| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001d30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001d40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001d50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001d60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001d70| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001d80| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001d90| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001da0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001db0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001dc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001dd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001de0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001df0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001e00| 2f 2a 20 47 65 74 6f 70 | 74 20 66 6f 72 20 47 4e |/* Getop|t for GN|
|00001e10| 55 2e 0a 20 20 20 4e 4f | 54 45 3a 20 67 65 74 6f |U.. NO|TE: geto|
|00001e20| 70 74 20 69 73 20 6e 6f | 77 20 70 61 72 74 20 6f |pt is no|w part o|
|00001e30| 66 20 74 68 65 20 43 20 | 6c 69 62 72 61 72 79 2c |f the C |library,|
|00001e40| 20 73 6f 20 69 66 20 79 | 6f 75 20 64 6f 6e 27 74 | so if y|ou don't|
|00001e50| 20 6b 6e 6f 77 20 77 68 | 61 74 0a 20 20 20 22 4b | know wh|at. "K|
|00001e60| 65 65 70 20 74 68 69 73 | 20 66 69 6c 65 20 6e 61 |eep this| file na|
|00001e70| 6d 65 2d 73 70 61 63 65 | 20 63 6c 65 61 6e 22 20 |me-space| clean" |
|00001e80| 6d 65 61 6e 73 2c 20 74 | 61 6c 6b 20 74 6f 20 72 |means, t|alk to r|
|00001e90| 6f 6c 61 6e 64 40 67 6e | 75 2e 61 69 2e 6d 69 74 |oland@gn|u.ai.mit|
|00001ea0| 2e 65 64 75 0a 20 20 20 | 62 65 66 6f 72 65 20 63 |.edu. |before c|
|00001eb0| 68 61 6e 67 69 6e 67 20 | 69 74 21 0a 0a 20 20 20 |hanging |it!.. |
|00001ec0| 43 6f 70 79 72 69 67 68 | 74 20 28 43 29 20 31 39 |Copyrigh|t (C) 19|
|00001ed0| 38 37 2c 20 38 38 2c 20 | 38 39 2c 20 39 30 2c 20 |87, 88, |89, 90, |
|00001ee0| 39 31 2c 20 39 32 2c 20 | 31 39 39 33 0a 20 20 20 |91, 92, |1993. |
|00001ef0| 09 46 72 65 65 20 53 6f | 66 74 77 61 72 65 20 46 |.Free So|ftware F|
|00001f00| 6f 75 6e 64 61 74 69 6f | 6e 2c 20 49 6e 63 2e 0a |oundatio|n, Inc..|
|00001f10| 0a 20 20 20 54 68 69 73 | 20 70 72 6f 67 72 61 6d |. This| program|
|00001f20| 20 69 73 20 66 72 65 65 | 20 73 6f 66 74 77 61 72 | is free| softwar|
|00001f30| 65 3b 20 79 6f 75 20 63 | 61 6e 20 72 65 64 69 73 |e; you c|an redis|
|00001f40| 74 72 69 62 75 74 65 20 | 69 74 20 61 6e 64 2f 6f |tribute |it and/o|
|00001f50| 72 20 6d 6f 64 69 66 79 | 20 69 74 0a 20 20 20 75 |r modify| it. u|
|00001f60| 6e 64 65 72 20 74 68 65 | 20 74 65 72 6d 73 20 6f |nder the| terms o|
|00001f70| 66 20 74 68 65 20 47 4e | 55 20 47 65 6e 65 72 61 |f the GN|U Genera|
|00001f80| 6c 20 50 75 62 6c 69 63 | 20 4c 69 63 65 6e 73 65 |l Public| License|
|00001f90| 20 61 73 20 70 75 62 6c | 69 73 68 65 64 20 62 79 | as publ|ished by|
|00001fa0| 20 74 68 65 0a 20 20 20 | 46 72 65 65 20 53 6f 66 | the. |Free Sof|
|00001fb0| 74 77 61 72 65 20 46 6f | 75 6e 64 61 74 69 6f 6e |tware Fo|undation|
|00001fc0| 3b 20 65 69 74 68 65 72 | 20 76 65 72 73 69 6f 6e |; either| version|
|00001fd0| 20 32 2c 20 6f 72 20 28 | 61 74 20 79 6f 75 72 20 | 2, or (|at your |
|00001fe0| 6f 70 74 69 6f 6e 29 20 | 61 6e 79 0a 20 20 20 6c |option) |any. l|
|00001ff0| 61 74 65 72 20 76 65 72 | 73 69 6f 6e 2e 0a 0a 20 |ater ver|sion... |
|00002000| 20 20 54 68 69 73 20 70 | 72 6f 67 72 61 6d 20 69 | This p|rogram i|
|00002010| 73 20 64 69 73 74 72 69 | 62 75 74 65 64 20 69 6e |s distri|buted in|
|00002020| 20 74 68 65 20 68 6f 70 | 65 20 74 68 61 74 20 69 | the hop|e that i|
|00002030| 74 20 77 69 6c 6c 20 62 | 65 20 75 73 65 66 75 6c |t will b|e useful|
|00002040| 2c 0a 20 20 20 62 75 74 | 20 57 49 54 48 4f 55 54 |,. but| WITHOUT|
|00002050| 20 41 4e 59 20 57 41 52 | 52 41 4e 54 59 3b 20 77 | ANY WAR|RANTY; w|
|00002060| 69 74 68 6f 75 74 20 65 | 76 65 6e 20 74 68 65 20 |ithout e|ven the |
|00002070| 69 6d 70 6c 69 65 64 20 | 77 61 72 72 61 6e 74 79 |implied |warranty|
|00002080| 20 6f 66 0a 20 20 20 4d | 45 52 43 48 41 4e 54 41 | of. M|ERCHANTA|
|00002090| 42 49 4c 49 54 59 20 6f | 72 20 46 49 54 4e 45 53 |BILITY o|r FITNES|
|000020a0| 53 20 46 4f 52 20 41 20 | 50 41 52 54 49 43 55 4c |S FOR A |PARTICUL|
|000020b0| 41 52 20 50 55 52 50 4f | 53 45 2e 20 20 53 65 65 |AR PURPO|SE. See|
|000020c0| 20 74 68 65 0a 20 20 20 | 47 4e 55 20 47 65 6e 65 | the. |GNU Gene|
|000020d0| 72 61 6c 20 50 75 62 6c | 69 63 20 4c 69 63 65 6e |ral Publ|ic Licen|
|000020e0| 73 65 20 66 6f 72 20 6d | 6f 72 65 20 64 65 74 61 |se for m|ore deta|
|000020f0| 69 6c 73 2e 0a 0a 20 20 | 20 59 6f 75 20 73 68 6f |ils... | You sho|
|00002100| 75 6c 64 20 68 61 76 65 | 20 72 65 63 65 69 76 65 |uld have| receive|
|00002110| 64 20 61 20 63 6f 70 79 | 20 6f 66 20 74 68 65 20 |d a copy| of the |
|00002120| 47 4e 55 20 47 65 6e 65 | 72 61 6c 20 50 75 62 6c |GNU Gene|ral Publ|
|00002130| 69 63 20 4c 69 63 65 6e | 73 65 0a 20 20 20 61 6c |ic Licen|se. al|
|00002140| 6f 6e 67 20 77 69 74 68 | 20 74 68 69 73 20 70 72 |ong with| this pr|
|00002150| 6f 67 72 61 6d 3b 20 69 | 66 20 6e 6f 74 2c 20 77 |ogram; i|f not, w|
|00002160| 72 69 74 65 20 74 6f 20 | 74 68 65 20 46 72 65 65 |rite to |the Free|
|00002170| 20 53 6f 66 74 77 61 72 | 65 0a 20 20 20 46 6f 75 | Softwar|e. Fou|
|00002180| 6e 64 61 74 69 6f 6e 2c | 20 36 37 35 20 4d 61 73 |ndation,| 675 Mas|
|00002190| 73 20 41 76 65 2c 20 43 | 61 6d 62 72 69 64 67 65 |s Ave, C|ambridge|
|000021a0| 2c 20 4d 41 20 30 32 31 | 33 39 2c 20 55 53 41 2e |, MA 021|39, USA.|
|000021b0| 20 20 2a 2f 0a 0c 0a 2f | 2a 20 4e 4f 54 45 21 21 | */.../|* NOTE!!|
|000021c0| 21 20 20 41 49 58 20 72 | 65 71 75 69 72 65 73 20 |! AIX r|equires |
|000021d0| 74 68 69 73 20 74 6f 20 | 62 65 20 74 68 65 20 66 |this to |be the f|
|000021e0| 69 72 73 74 20 74 68 69 | 6e 67 20 69 6e 20 74 68 |irst thi|ng in th|
|000021f0| 65 20 66 69 6c 65 2e 0a | 20 20 20 44 6f 20 6e 6f |e file..| Do no|
|00002200| 74 20 70 75 74 20 41 4e | 59 54 48 49 4e 47 20 62 |t put AN|YTHING b|
|00002210| 65 66 6f 72 65 20 69 74 | 21 20 20 2a 2f 0a 23 69 |efore it|! */.#i|
|00002220| 66 20 21 64 65 66 69 6e | 65 64 20 28 5f 5f 47 4e |f !defin|ed (__GN|
|00002230| 55 43 5f 5f 29 20 26 26 | 20 64 65 66 69 6e 65 64 |UC__) &&| defined|
|00002240| 20 28 5f 41 49 58 29 0a | 20 23 70 72 61 67 6d 61 | (_AIX).| #pragma|
|00002250| 20 61 6c 6c 6f 63 61 0a | 23 65 6e 64 69 66 0a 0a | alloca.|#endif..|
|00002260| 23 69 66 64 65 66 20 48 | 41 56 45 5f 43 4f 4e 46 |#ifdef H|AVE_CONF|
|00002270| 49 47 5f 48 0a 23 69 6e | 63 6c 75 64 65 20 22 63 |IG_H.#in|clude "c|
|00002280| 6f 6e 66 69 67 2e 68 22 | 0a 23 65 6e 64 69 66 0a |onfig.h"|.#endif.|
|00002290| 0a 23 69 66 64 65 66 20 | 5f 5f 47 4e 55 43 5f 5f |.#ifdef |__GNUC__|
|000022a0| 0a 23 64 65 66 69 6e 65 | 20 61 6c 6c 6f 63 61 20 |.#define| alloca |
|000022b0| 5f 5f 62 75 69 6c 74 69 | 6e 5f 61 6c 6c 6f 63 61 |__builti|n_alloca|
|000022c0| 0a 23 65 6c 73 65 20 2f | 2a 20 6e 6f 74 20 5f 5f |.#else /|* not __|
|000022d0| 47 4e 55 43 5f 5f 20 2a | 2f 0a 23 69 66 20 64 65 |GNUC__ *|/.#if de|
|000022e0| 66 69 6e 65 64 20 28 48 | 41 56 45 5f 41 4c 4c 4f |fined (H|AVE_ALLO|
|000022f0| 43 41 5f 48 29 20 7c 7c | 20 28 64 65 66 69 6e 65 |CA_H) ||| (define|
|00002300| 64 28 73 70 61 72 63 29 | 20 26 26 20 28 64 65 66 |d(sparc)| && (def|
|00002310| 69 6e 65 64 28 73 75 6e | 29 20 7c 7c 20 28 21 64 |ined(sun|) || (!d|
|00002320| 65 66 69 6e 65 64 28 55 | 53 47 29 20 26 26 20 21 |efined(U|SG) && !|
|00002330| 64 65 66 69 6e 65 64 28 | 53 56 52 34 29 20 26 26 |defined(|SVR4) &&|
|00002340| 20 21 64 65 66 69 6e 65 | 64 28 5f 5f 73 76 72 34 | !define|d(__svr4|
|00002350| 5f 5f 29 29 29 29 0a 23 | 69 6e 63 6c 75 64 65 20 |__)))).#|include |
|00002360| 3c 61 6c 6c 6f 63 61 2e | 68 3e 0a 23 65 6c 73 65 |<alloca.|h>.#else|
|00002370| 0a 23 69 66 6e 64 65 66 | 20 5f 41 49 58 0a 63 68 |.#ifndef| _AIX.ch|
|00002380| 61 72 20 2a 61 6c 6c 6f | 63 61 20 28 29 3b 0a 23 |ar *allo|ca ();.#|
|00002390| 65 6e 64 69 66 0a 23 65 | 6e 64 69 66 20 2f 2a 20 |endif.#e|ndif /* |
|000023a0| 61 6c 6c 6f 63 61 2e 68 | 20 2a 2f 0a 23 65 6e 64 |alloca.h| */.#end|
|000023b0| 69 66 20 2f 2a 20 6e 6f | 74 20 5f 5f 47 4e 55 43 |if /* no|t __GNUC|
|000023c0| 5f 5f 20 2a 2f 0a 0a 23 | 69 66 20 21 5f 5f 53 54 |__ */..#|if !__ST|
|000023d0| 44 43 5f 5f 20 26 26 20 | 21 64 65 66 69 6e 65 64 |DC__ && |!defined|
|000023e0| 28 63 6f 6e 73 74 29 20 | 26 26 20 49 4e 5f 47 43 |(const) |&& IN_GC|
|000023f0| 43 0a 23 64 65 66 69 6e | 65 20 63 6f 6e 73 74 0a |C.#defin|e const.|
|00002400| 23 65 6e 64 69 66 0a 0a | 2f 2a 20 54 68 69 73 20 |#endif..|/* This |
|00002410| 74 65 6c 6c 73 20 41 6c | 70 68 61 20 4f 53 46 2f |tells Al|pha OSF/|
|00002420| 31 20 6e 6f 74 20 74 6f | 20 64 65 66 69 6e 65 20 |1 not to| define |
|00002430| 61 20 67 65 74 6f 70 74 | 20 70 72 6f 74 6f 74 79 |a getopt| prototy|
|00002440| 70 65 20 69 6e 20 3c 73 | 74 64 69 6f 2e 68 3e 2e |pe in <s|tdio.h>.|
|00002450| 20 20 2a 2f 0a 23 69 66 | 6e 64 65 66 20 5f 4e 4f | */.#if|ndef _NO|
|00002460| 5f 50 52 4f 54 4f 0a 23 | 64 65 66 69 6e 65 20 5f |_PROTO.#|define _|
|00002470| 4e 4f 5f 50 52 4f 54 4f | 0a 23 65 6e 64 69 66 0a |NO_PROTO|.#endif.|
|00002480| 0a 23 69 6e 63 6c 75 64 | 65 20 3c 73 74 64 69 6f |.#includ|e <stdio|
|00002490| 2e 68 3e 0a 0a 2f 2a 20 | 43 6f 6d 6d 65 6e 74 20 |.h>../* |Comment |
|000024a0| 6f 75 74 20 61 6c 6c 20 | 74 68 69 73 20 63 6f 64 |out all |this cod|
|000024b0| 65 20 69 66 20 77 65 20 | 61 72 65 20 75 73 69 6e |e if we |are usin|
|000024c0| 67 20 74 68 65 20 47 4e | 55 20 43 20 4c 69 62 72 |g the GN|U C Libr|
|000024d0| 61 72 79 2c 20 61 6e 64 | 20 61 72 65 20 6e 6f 74 |ary, and| are not|
|000024e0| 0a 20 20 20 61 63 74 75 | 61 6c 6c 79 20 63 6f 6d |. actu|ally com|
|000024f0| 70 69 6c 69 6e 67 20 74 | 68 65 20 6c 69 62 72 61 |piling t|he libra|
|00002500| 72 79 20 69 74 73 65 6c | 66 2e 20 20 54 68 69 73 |ry itsel|f. This|
|00002510| 20 63 6f 64 65 20 69 73 | 20 70 61 72 74 20 6f 66 | code is| part of|
|00002520| 20 74 68 65 20 47 4e 55 | 20 43 0a 20 20 20 4c 69 | the GNU| C. Li|
|00002530| 62 72 61 72 79 2c 20 62 | 75 74 20 61 6c 73 6f 20 |brary, b|ut also |
|00002540| 69 6e 63 6c 75 64 65 64 | 20 69 6e 20 6d 61 6e 79 |included| in many|
|00002550| 20 6f 74 68 65 72 20 47 | 4e 55 20 64 69 73 74 72 | other G|NU distr|
|00002560| 69 62 75 74 69 6f 6e 73 | 2e 20 20 43 6f 6d 70 69 |ibutions|. Compi|
|00002570| 6c 69 6e 67 0a 20 20 20 | 61 6e 64 20 6c 69 6e 6b |ling. |and link|
|00002580| 69 6e 67 20 69 6e 20 74 | 68 69 73 20 63 6f 64 65 |ing in t|his code|
|00002590| 20 69 73 20 61 20 77 61 | 73 74 65 20 77 68 65 6e | is a wa|ste when|
|000025a0| 20 75 73 69 6e 67 20 74 | 68 65 20 47 4e 55 20 43 | using t|he GNU C|
|000025b0| 20 6c 69 62 72 61 72 79 | 0a 20 20 20 28 65 73 70 | library|. (esp|
|000025c0| 65 63 69 61 6c 6c 79 20 | 69 66 20 69 74 20 69 73 |ecially |if it is|
|000025d0| 20 61 20 73 68 61 72 65 | 64 20 6c 69 62 72 61 72 | a share|d librar|
|000025e0| 79 29 2e 20 20 52 61 74 | 68 65 72 20 74 68 61 6e |y). Rat|her than|
|000025f0| 20 68 61 76 69 6e 67 20 | 65 76 65 72 79 20 47 4e | having |every GN|
|00002600| 55 0a 20 20 20 70 72 6f | 67 72 61 6d 20 75 6e 64 |U. pro|gram und|
|00002610| 65 72 73 74 61 6e 64 20 | 60 63 6f 6e 66 69 67 75 |erstand |`configu|
|00002620| 72 65 20 2d 2d 77 69 74 | 68 2d 67 6e 75 2d 6c 69 |re --wit|h-gnu-li|
|00002630| 62 63 27 20 61 6e 64 20 | 6f 6d 69 74 20 74 68 65 |bc' and |omit the|
|00002640| 20 6f 62 6a 65 63 74 20 | 66 69 6c 65 73 2c 0a 20 | object |files,. |
|00002650| 20 20 69 74 20 69 73 20 | 73 69 6d 70 6c 65 72 20 | it is |simpler |
|00002660| 74 6f 20 6a 75 73 74 20 | 64 6f 20 74 68 69 73 20 |to just |do this |
|00002670| 69 6e 20 74 68 65 20 73 | 6f 75 72 63 65 20 66 6f |in the s|ource fo|
|00002680| 72 20 65 61 63 68 20 73 | 75 63 68 20 66 69 6c 65 |r each s|uch file|
|00002690| 2e 20 20 2a 2f 0a 0a 23 | 69 66 20 64 65 66 69 6e |. */..#|if defin|
|000026a0| 65 64 20 28 5f 4c 49 42 | 43 29 20 7c 7c 20 21 64 |ed (_LIB|C) || !d|
|000026b0| 65 66 69 6e 65 64 20 28 | 5f 5f 47 4e 55 5f 4c 49 |efined (|__GNU_LI|
|000026c0| 42 52 41 52 59 5f 5f 29 | 0a 0a 0a 2f 2a 20 54 68 |BRARY__)|.../* Th|
|000026d0| 69 73 20 6e 65 65 64 73 | 20 74 6f 20 63 6f 6d 65 |is needs| to come|
|000026e0| 20 61 66 74 65 72 20 73 | 6f 6d 65 20 6c 69 62 72 | after s|ome libr|
|000026f0| 61 72 79 20 23 69 6e 63 | 6c 75 64 65 0a 20 20 20 |ary #inc|lude. |
|00002700| 74 6f 20 67 65 74 20 5f | 5f 47 4e 55 5f 4c 49 42 |to get _|_GNU_LIB|
|00002710| 52 41 52 59 5f 5f 20 64 | 65 66 69 6e 65 64 2e 20 |RARY__ d|efined. |
|00002720| 20 2a 2f 0a 23 69 66 64 | 65 66 09 5f 5f 47 4e 55 | */.#ifd|ef.__GNU|
|00002730| 5f 4c 49 42 52 41 52 59 | 5f 5f 0a 23 75 6e 64 65 |_LIBRARY|__.#unde|
|00002740| 66 09 61 6c 6c 6f 63 61 | 0a 2f 2a 20 44 6f 6e 27 |f.alloca|./* Don'|
|00002750| 74 20 69 6e 63 6c 75 64 | 65 20 73 74 64 6c 69 62 |t includ|e stdlib|
|00002760| 2e 68 20 66 6f 72 20 6e | 6f 6e 2d 47 4e 55 20 43 |.h for n|on-GNU C|
|00002770| 20 6c 69 62 72 61 72 69 | 65 73 20 62 65 63 61 75 | librari|es becau|
|00002780| 73 65 20 73 6f 6d 65 20 | 6f 66 20 74 68 65 6d 0a |se some |of them.|
|00002790| 20 20 20 63 6f 6e 74 61 | 69 6e 20 63 6f 6e 66 6c | conta|in confl|
|000027a0| 69 63 74 69 6e 67 20 70 | 72 6f 74 6f 74 79 70 65 |icting p|rototype|
|000027b0| 73 20 66 6f 72 20 67 65 | 74 6f 70 74 2e 20 20 2a |s for ge|topt. *|
|000027c0| 2f 0a 23 69 6e 63 6c 75 | 64 65 20 3c 73 74 64 6c |/.#inclu|de <stdl|
|000027d0| 69 62 2e 68 3e 0a 23 65 | 6c 73 65 09 2f 2a 20 4e |ib.h>.#e|lse./* N|
|000027e0| 6f 74 20 47 4e 55 20 43 | 20 6c 69 62 72 61 72 79 |ot GNU C| library|
|000027f0| 2e 20 20 2a 2f 0a 23 64 | 65 66 69 6e 65 09 5f 5f |. */.#d|efine.__|
|00002800| 61 6c 6c 6f 63 61 09 61 | 6c 6c 6f 63 61 0a 23 65 |alloca.a|lloca.#e|
|00002810| 6e 64 69 66 09 2f 2a 20 | 47 4e 55 20 43 20 6c 69 |ndif./* |GNU C li|
|00002820| 62 72 61 72 79 2e 20 20 | 2a 2f 0a 0a 2f 2a 20 49 |brary. |*/../* I|
|00002830| 66 20 47 45 54 4f 50 54 | 5f 43 4f 4d 50 41 54 20 |f GETOPT|_COMPAT |
|00002840| 69 73 20 64 65 66 69 6e | 65 64 2c 20 60 2b 27 20 |is defin|ed, `+' |
|00002850| 61 73 20 77 65 6c 6c 20 | 61 73 20 60 2d 2d 27 20 |as well |as `--' |
|00002860| 63 61 6e 20 69 6e 74 72 | 6f 64 75 63 65 20 61 0a |can intr|oduce a.|
|00002870| 20 20 20 6c 6f 6e 67 2d | 6e 61 6d 65 64 20 6f 70 | long-|named op|
|00002880| 74 69 6f 6e 2e 20 20 42 | 65 63 61 75 73 65 20 74 |tion. B|ecause t|
|00002890| 68 69 73 20 69 73 20 6e | 6f 74 20 50 4f 53 49 58 |his is n|ot POSIX|
|000028a0| 2e 32 20 63 6f 6d 70 6c | 69 61 6e 74 2c 20 69 74 |.2 compl|iant, it|
|000028b0| 20 69 73 0a 20 20 20 62 | 65 69 6e 67 20 70 68 61 | is. b|eing pha|
|000028c0| 73 65 64 20 6f 75 74 2e | 20 20 2a 2f 0a 2f 2a 20 |sed out.| */./* |
|000028d0| 23 64 65 66 69 6e 65 20 | 47 45 54 4f 50 54 5f 43 |#define |GETOPT_C|
|000028e0| 4f 4d 50 41 54 20 2a 2f | 0a 0a 2f 2a 20 54 68 69 |OMPAT */|../* Thi|
|000028f0| 73 20 76 65 72 73 69 6f | 6e 20 6f 66 20 60 67 65 |s versio|n of `ge|
|00002900| 74 6f 70 74 27 20 61 70 | 70 65 61 72 73 20 74 6f |topt' ap|pears to|
|00002910| 20 74 68 65 20 63 61 6c | 6c 65 72 20 6c 69 6b 65 | the cal|ler like|
|00002920| 20 73 74 61 6e 64 61 72 | 64 20 55 6e 69 78 20 60 | standar|d Unix `|
|00002930| 67 65 74 6f 70 74 27 0a | 20 20 20 62 75 74 20 69 |getopt'.| but i|
|00002940| 74 20 62 65 68 61 76 65 | 73 20 64 69 66 66 65 72 |t behave|s differ|
|00002950| 65 6e 74 6c 79 20 66 6f | 72 20 74 68 65 20 75 73 |ently fo|r the us|
|00002960| 65 72 2c 20 73 69 6e 63 | 65 20 69 74 20 61 6c 6c |er, sinc|e it all|
|00002970| 6f 77 73 20 74 68 65 20 | 75 73 65 72 0a 20 20 20 |ows the |user. |
|00002980| 74 6f 20 69 6e 74 65 72 | 73 70 65 72 73 65 20 74 |to inter|sperse t|
|00002990| 68 65 20 6f 70 74 69 6f | 6e 73 20 77 69 74 68 20 |he optio|ns with |
|000029a0| 74 68 65 20 6f 74 68 65 | 72 20 61 72 67 75 6d 65 |the othe|r argume|
|000029b0| 6e 74 73 2e 0a 0a 20 20 | 20 41 73 20 60 67 65 74 |nts... | As `get|
|000029c0| 6f 70 74 27 20 77 6f 72 | 6b 73 2c 20 69 74 20 70 |opt' wor|ks, it p|
|000029d0| 65 72 6d 75 74 65 73 20 | 74 68 65 20 65 6c 65 6d |ermutes |the elem|
|000029e0| 65 6e 74 73 20 6f 66 20 | 41 52 47 56 20 73 6f 20 |ents of |ARGV so |
|000029f0| 74 68 61 74 2c 0a 20 20 | 20 77 68 65 6e 20 69 74 |that,. | when it|
|00002a00| 20 69 73 20 64 6f 6e 65 | 2c 20 61 6c 6c 20 74 68 | is done|, all th|
|00002a10| 65 20 6f 70 74 69 6f 6e | 73 20 70 72 65 63 65 64 |e option|s preced|
|00002a20| 65 20 65 76 65 72 79 74 | 68 69 6e 67 20 65 6c 73 |e everyt|hing els|
|00002a30| 65 2e 20 20 54 68 75 73 | 0a 20 20 20 61 6c 6c 20 |e. Thus|. all |
|00002a40| 61 70 70 6c 69 63 61 74 | 69 6f 6e 20 70 72 6f 67 |applicat|ion prog|
|00002a50| 72 61 6d 73 20 61 72 65 | 20 65 78 74 65 6e 64 65 |rams are| extende|
|00002a60| 64 20 74 6f 20 68 61 6e | 64 6c 65 20 66 6c 65 78 |d to han|dle flex|
|00002a70| 69 62 6c 65 20 61 72 67 | 75 6d 65 6e 74 20 6f 72 |ible arg|ument or|
|00002a80| 64 65 72 2e 0a 0a 20 20 | 20 53 65 74 74 69 6e 67 |der... | Setting|
|00002a90| 20 74 68 65 20 65 6e 76 | 69 72 6f 6e 6d 65 6e 74 | the env|ironment|
|00002aa0| 20 76 61 72 69 61 62 6c | 65 20 50 4f 53 49 58 4c | variabl|e POSIXL|
|00002ab0| 59 5f 43 4f 52 52 45 43 | 54 20 64 69 73 61 62 6c |Y_CORREC|T disabl|
|00002ac0| 65 73 20 70 65 72 6d 75 | 74 61 74 69 6f 6e 2e 0a |es permu|tation..|
|00002ad0| 20 20 20 54 68 65 6e 20 | 74 68 65 20 62 65 68 61 | Then |the beha|
|00002ae0| 76 69 6f 72 20 69 73 20 | 63 6f 6d 70 6c 65 74 65 |vior is |complete|
|00002af0| 6c 79 20 73 74 61 6e 64 | 61 72 64 2e 0a 0a 20 20 |ly stand|ard... |
|00002b00| 20 47 4e 55 20 61 70 70 | 6c 69 63 61 74 69 6f 6e | GNU app|lication|
|00002b10| 20 70 72 6f 67 72 61 6d | 73 20 63 61 6e 20 75 73 | program|s can us|
|00002b20| 65 20 61 20 74 68 69 72 | 64 20 61 6c 74 65 72 6e |e a thir|d altern|
|00002b30| 61 74 69 76 65 20 6d 6f | 64 65 20 69 6e 20 77 68 |ative mo|de in wh|
|00002b40| 69 63 68 0a 20 20 20 74 | 68 65 79 20 63 61 6e 20 |ich. t|hey can |
|00002b50| 64 69 73 74 69 6e 67 75 | 69 73 68 20 74 68 65 20 |distingu|ish the |
|00002b60| 72 65 6c 61 74 69 76 65 | 20 6f 72 64 65 72 20 6f |relative| order o|
|00002b70| 66 20 6f 70 74 69 6f 6e | 73 20 61 6e 64 20 6f 74 |f option|s and ot|
|00002b80| 68 65 72 20 61 72 67 75 | 6d 65 6e 74 73 2e 20 20 |her argu|ments. |
|00002b90| 2a 2f 0a 0a 23 69 6e 63 | 6c 75 64 65 20 22 67 65 |*/..#inc|lude "ge|
|00002ba0| 74 6f 70 74 2e 68 22 0a | 0a 2f 2a 20 46 6f 72 20 |topt.h".|./* For |
|00002bb0| 63 6f 6d 6d 75 6e 69 63 | 61 74 69 6f 6e 20 66 72 |communic|ation fr|
|00002bc0| 6f 6d 20 60 67 65 74 6f | 70 74 27 20 74 6f 20 74 |om `geto|pt' to t|
|00002bd0| 68 65 20 63 61 6c 6c 65 | 72 2e 0a 20 20 20 57 68 |he calle|r.. Wh|
|00002be0| 65 6e 20 60 67 65 74 6f | 70 74 27 20 66 69 6e 64 |en `geto|pt' find|
|00002bf0| 73 20 61 6e 20 6f 70 74 | 69 6f 6e 20 74 68 61 74 |s an opt|ion that|
|00002c00| 20 74 61 6b 65 73 20 61 | 6e 20 61 72 67 75 6d 65 | takes a|n argume|
|00002c10| 6e 74 2c 0a 20 20 20 74 | 68 65 20 61 72 67 75 6d |nt,. t|he argum|
|00002c20| 65 6e 74 20 76 61 6c 75 | 65 20 69 73 20 72 65 74 |ent valu|e is ret|
|00002c30| 75 72 6e 65 64 20 68 65 | 72 65 2e 0a 20 20 20 41 |urned he|re.. A|
|00002c40| 6c 73 6f 2c 20 77 68 65 | 6e 20 60 6f 72 64 65 72 |lso, whe|n `order|
|00002c50| 69 6e 67 27 20 69 73 20 | 52 45 54 55 52 4e 5f 49 |ing' is |RETURN_I|
|00002c60| 4e 5f 4f 52 44 45 52 2c | 0a 20 20 20 65 61 63 68 |N_ORDER,|. each|
|00002c70| 20 6e 6f 6e 2d 6f 70 74 | 69 6f 6e 20 41 52 47 56 | non-opt|ion ARGV|
|00002c80| 2d 65 6c 65 6d 65 6e 74 | 20 69 73 20 72 65 74 75 |-element| is retu|
|00002c90| 72 6e 65 64 20 68 65 72 | 65 2e 20 20 2a 2f 0a 0a |rned her|e. */..|
|00002ca0| 63 68 61 72 20 2a 6f 70 | 74 61 72 67 20 3d 20 30 |char *op|targ = 0|
|00002cb0| 3b 0a 0a 2f 2a 20 49 6e | 64 65 78 20 69 6e 20 41 |;../* In|dex in A|
|00002cc0| 52 47 56 20 6f 66 20 74 | 68 65 20 6e 65 78 74 20 |RGV of t|he next |
|00002cd0| 65 6c 65 6d 65 6e 74 20 | 74 6f 20 62 65 20 73 63 |element |to be sc|
|00002ce0| 61 6e 6e 65 64 2e 0a 20 | 20 20 54 68 69 73 20 69 |anned.. | This i|
|00002cf0| 73 20 75 73 65 64 20 66 | 6f 72 20 63 6f 6d 6d 75 |s used f|or commu|
|00002d00| 6e 69 63 61 74 69 6f 6e | 20 74 6f 20 61 6e 64 20 |nication| to and |
|00002d10| 66 72 6f 6d 20 74 68 65 | 20 63 61 6c 6c 65 72 0a |from the| caller.|
|00002d20| 20 20 20 61 6e 64 20 66 | 6f 72 20 63 6f 6d 6d 75 | and f|or commu|
|00002d30| 6e 69 63 61 74 69 6f 6e | 20 62 65 74 77 65 65 6e |nication| between|
|00002d40| 20 73 75 63 63 65 73 73 | 69 76 65 20 63 61 6c 6c | success|ive call|
|00002d50| 73 20 74 6f 20 60 67 65 | 74 6f 70 74 27 2e 0a 0a |s to `ge|topt'...|
|00002d60| 20 20 20 4f 6e 20 65 6e | 74 72 79 20 74 6f 20 60 | On en|try to `|
|00002d70| 67 65 74 6f 70 74 27 2c | 20 7a 65 72 6f 20 6d 65 |getopt',| zero me|
|00002d80| 61 6e 73 20 74 68 69 73 | 20 69 73 20 74 68 65 20 |ans this| is the |
|00002d90| 66 69 72 73 74 20 63 61 | 6c 6c 3b 20 69 6e 69 74 |first ca|ll; init|
|00002da0| 69 61 6c 69 7a 65 2e 0a | 0a 20 20 20 57 68 65 6e |ialize..|. When|
|00002db0| 20 60 67 65 74 6f 70 74 | 27 20 72 65 74 75 72 6e | `getopt|' return|
|00002dc0| 73 20 45 4f 46 2c 20 74 | 68 69 73 20 69 73 20 74 |s EOF, t|his is t|
|00002dd0| 68 65 20 69 6e 64 65 78 | 20 6f 66 20 74 68 65 20 |he index| of the |
|00002de0| 66 69 72 73 74 20 6f 66 | 20 74 68 65 0a 20 20 20 |first of| the. |
|00002df0| 6e 6f 6e 2d 6f 70 74 69 | 6f 6e 20 65 6c 65 6d 65 |non-opti|on eleme|
|00002e00| 6e 74 73 20 74 68 61 74 | 20 74 68 65 20 63 61 6c |nts that| the cal|
|00002e10| 6c 65 72 20 73 68 6f 75 | 6c 64 20 69 74 73 65 6c |ler shou|ld itsel|
|00002e20| 66 20 73 63 61 6e 2e 0a | 0a 20 20 20 4f 74 68 65 |f scan..|. Othe|
|00002e30| 72 77 69 73 65 2c 20 60 | 6f 70 74 69 6e 64 27 20 |rwise, `|optind' |
|00002e40| 63 6f 6d 6d 75 6e 69 63 | 61 74 65 73 20 66 72 6f |communic|ates fro|
|00002e50| 6d 20 6f 6e 65 20 63 61 | 6c 6c 20 74 6f 20 74 68 |m one ca|ll to th|
|00002e60| 65 20 6e 65 78 74 0a 20 | 20 20 68 6f 77 20 6d 75 |e next. | how mu|
|00002e70| 63 68 20 6f 66 20 41 52 | 47 56 20 68 61 73 20 62 |ch of AR|GV has b|
|00002e80| 65 65 6e 20 73 63 61 6e | 6e 65 64 20 73 6f 20 66 |een scan|ned so f|
|00002e90| 61 72 2e 20 20 2a 2f 0a | 0a 2f 2a 20 58 58 58 20 |ar. */.|./* XXX |
|00002ea0| 31 30 30 33 2e 32 20 73 | 61 79 73 20 74 68 69 73 |1003.2 s|ays this|
|00002eb0| 20 6d 75 73 74 20 62 65 | 20 31 20 62 65 66 6f 72 | must be| 1 befor|
|00002ec0| 65 20 61 6e 79 20 63 61 | 6c 6c 2e 20 20 2a 2f 0a |e any ca|ll. */.|
|00002ed0| 69 6e 74 20 6f 70 74 69 | 6e 64 20 3d 20 30 3b 0a |int opti|nd = 0;.|
|00002ee0| 0a 2f 2a 20 54 68 65 20 | 6e 65 78 74 20 63 68 61 |./* The |next cha|
|00002ef0| 72 20 74 6f 20 62 65 20 | 73 63 61 6e 6e 65 64 20 |r to be |scanned |
|00002f00| 69 6e 20 74 68 65 20 6f | 70 74 69 6f 6e 2d 65 6c |in the o|ption-el|
|00002f10| 65 6d 65 6e 74 0a 20 20 | 20 69 6e 20 77 68 69 63 |ement. | in whic|
|00002f20| 68 20 74 68 65 20 6c 61 | 73 74 20 6f 70 74 69 6f |h the la|st optio|
|00002f30| 6e 20 63 68 61 72 61 63 | 74 65 72 20 77 65 20 72 |n charac|ter we r|
|00002f40| 65 74 75 72 6e 65 64 20 | 77 61 73 20 66 6f 75 6e |eturned |was foun|
|00002f50| 64 2e 0a 20 20 20 54 68 | 69 73 20 61 6c 6c 6f 77 |d.. Th|is allow|
|00002f60| 73 20 75 73 20 74 6f 20 | 70 69 63 6b 20 75 70 20 |s us to |pick up |
|00002f70| 74 68 65 20 73 63 61 6e | 20 77 68 65 72 65 20 77 |the scan| where w|
|00002f80| 65 20 6c 65 66 74 20 6f | 66 66 2e 0a 0a 20 20 20 |e left o|ff... |
|00002f90| 49 66 20 74 68 69 73 20 | 69 73 20 7a 65 72 6f 2c |If this |is zero,|
|00002fa0| 20 6f 72 20 61 20 6e 75 | 6c 6c 20 73 74 72 69 6e | or a nu|ll strin|
|00002fb0| 67 2c 20 69 74 20 6d 65 | 61 6e 73 20 72 65 73 75 |g, it me|ans resu|
|00002fc0| 6d 65 20 74 68 65 20 73 | 63 61 6e 0a 20 20 20 62 |me the s|can. b|
|00002fd0| 79 20 61 64 76 61 6e 63 | 69 6e 67 20 74 6f 20 74 |y advanc|ing to t|
|00002fe0| 68 65 20 6e 65 78 74 20 | 41 52 47 56 2d 65 6c 65 |he next |ARGV-ele|
|00002ff0| 6d 65 6e 74 2e 20 20 2a | 2f 0a 0a 73 74 61 74 69 |ment. *|/..stati|
|00003000| 63 20 63 68 61 72 20 2a | 6e 65 78 74 63 68 61 72 |c char *|nextchar|
|00003010| 3b 0a 0a 2f 2a 20 43 61 | 6c 6c 65 72 73 20 73 74 |;../* Ca|llers st|
|00003020| 6f 72 65 20 7a 65 72 6f | 20 68 65 72 65 20 74 6f |ore zero| here to|
|00003030| 20 69 6e 68 69 62 69 74 | 20 74 68 65 20 65 72 72 | inhibit| the err|
|00003040| 6f 72 20 6d 65 73 73 61 | 67 65 0a 20 20 20 66 6f |or messa|ge. fo|
|00003050| 72 20 75 6e 72 65 63 6f | 67 6e 69 7a 65 64 20 6f |r unreco|gnized o|
|00003060| 70 74 69 6f 6e 73 2e 20 | 20 2a 2f 0a 0a 69 6e 74 |ptions. | */..int|
|00003070| 20 6f 70 74 65 72 72 20 | 3d 20 31 3b 0a 0a 2f 2a | opterr |= 1;../*|
|00003080| 20 53 65 74 20 74 6f 20 | 61 6e 20 6f 70 74 69 6f | Set to |an optio|
|00003090| 6e 20 63 68 61 72 61 63 | 74 65 72 20 77 68 69 63 |n charac|ter whic|
|000030a0| 68 20 77 61 73 20 75 6e | 72 65 63 6f 67 6e 69 7a |h was un|recogniz|
|000030b0| 65 64 2e 0a 20 20 20 54 | 68 69 73 20 6d 75 73 74 |ed.. T|his must|
|000030c0| 20 62 65 20 69 6e 69 74 | 69 61 6c 69 7a 65 64 20 | be init|ialized |
|000030d0| 6f 6e 20 73 6f 6d 65 20 | 73 79 73 74 65 6d 73 20 |on some |systems |
|000030e0| 74 6f 20 61 76 6f 69 64 | 20 6c 69 6e 6b 69 6e 67 |to avoid| linking|
|000030f0| 20 69 6e 20 74 68 65 0a | 20 20 20 73 79 73 74 65 | in the.| syste|
|00003100| 6d 27 73 20 6f 77 6e 20 | 67 65 74 6f 70 74 20 69 |m's own |getopt i|
|00003110| 6d 70 6c 65 6d 65 6e 74 | 61 74 69 6f 6e 2e 20 20 |mplement|ation. |
|00003120| 2a 2f 0a 0a 69 6e 74 20 | 6f 70 74 6f 70 74 20 3d |*/..int |optopt =|
|00003130| 20 27 3f 27 3b 0a 0a 2f | 2a 20 44 65 73 63 72 69 | '?';../|* Descri|
|00003140| 62 65 20 68 6f 77 20 74 | 6f 20 64 65 61 6c 20 77 |be how t|o deal w|
|00003150| 69 74 68 20 6f 70 74 69 | 6f 6e 73 20 74 68 61 74 |ith opti|ons that|
|00003160| 20 66 6f 6c 6c 6f 77 20 | 6e 6f 6e 2d 6f 70 74 69 | follow |non-opti|
|00003170| 6f 6e 20 41 52 47 56 2d | 65 6c 65 6d 65 6e 74 73 |on ARGV-|elements|
|00003180| 2e 0a 0a 20 20 20 49 66 | 20 74 68 65 20 63 61 6c |... If| the cal|
|00003190| 6c 65 72 20 64 69 64 20 | 6e 6f 74 20 73 70 65 63 |ler did |not spec|
|000031a0| 69 66 79 20 61 6e 79 74 | 68 69 6e 67 2c 0a 20 20 |ify anyt|hing,. |
|000031b0| 20 74 68 65 20 64 65 66 | 61 75 6c 74 20 69 73 20 | the def|ault is |
|000031c0| 52 45 51 55 49 52 45 5f | 4f 52 44 45 52 20 69 66 |REQUIRE_|ORDER if|
|000031d0| 20 74 68 65 20 65 6e 76 | 69 72 6f 6e 6d 65 6e 74 | the env|ironment|
|000031e0| 20 76 61 72 69 61 62 6c | 65 0a 20 20 20 50 4f 53 | variabl|e. POS|
|000031f0| 49 58 4c 59 5f 43 4f 52 | 52 45 43 54 20 69 73 20 |IXLY_COR|RECT is |
|00003200| 64 65 66 69 6e 65 64 2c | 20 50 45 52 4d 55 54 45 |defined,| PERMUTE|
|00003210| 20 6f 74 68 65 72 77 69 | 73 65 2e 0a 0a 20 20 20 | otherwi|se... |
|00003220| 52 45 51 55 49 52 45 5f | 4f 52 44 45 52 20 6d 65 |REQUIRE_|ORDER me|
|00003230| 61 6e 73 20 64 6f 6e 27 | 74 20 72 65 63 6f 67 6e |ans don'|t recogn|
|00003240| 69 7a 65 20 74 68 65 6d | 20 61 73 20 6f 70 74 69 |ize them| as opti|
|00003250| 6f 6e 73 3b 0a 20 20 20 | 73 74 6f 70 20 6f 70 74 |ons;. |stop opt|
|00003260| 69 6f 6e 20 70 72 6f 63 | 65 73 73 69 6e 67 20 77 |ion proc|essing w|
|00003270| 68 65 6e 20 74 68 65 20 | 66 69 72 73 74 20 6e 6f |hen the |first no|
|00003280| 6e 2d 6f 70 74 69 6f 6e | 20 69 73 20 73 65 65 6e |n-option| is seen|
|00003290| 2e 0a 20 20 20 54 68 69 | 73 20 69 73 20 77 68 61 |.. Thi|s is wha|
|000032a0| 74 20 55 6e 69 78 20 64 | 6f 65 73 2e 0a 20 20 20 |t Unix d|oes.. |
|000032b0| 54 68 69 73 20 6d 6f 64 | 65 20 6f 66 20 6f 70 65 |This mod|e of ope|
|000032c0| 72 61 74 69 6f 6e 20 69 | 73 20 73 65 6c 65 63 74 |ration i|s select|
|000032d0| 65 64 20 62 79 20 65 69 | 74 68 65 72 20 73 65 74 |ed by ei|ther set|
|000032e0| 74 69 6e 67 20 74 68 65 | 20 65 6e 76 69 72 6f 6e |ting the| environ|
|000032f0| 6d 65 6e 74 0a 20 20 20 | 76 61 72 69 61 62 6c 65 |ment. |variable|
|00003300| 20 50 4f 53 49 58 4c 59 | 5f 43 4f 52 52 45 43 54 | POSIXLY|_CORRECT|
|00003310| 2c 20 6f 72 20 75 73 69 | 6e 67 20 60 2b 27 20 61 |, or usi|ng `+' a|
|00003320| 73 20 74 68 65 20 66 69 | 72 73 74 20 63 68 61 72 |s the fi|rst char|
|00003330| 61 63 74 65 72 0a 20 20 | 20 6f 66 20 74 68 65 20 |acter. | of the |
|00003340| 6c 69 73 74 20 6f 66 20 | 6f 70 74 69 6f 6e 20 63 |list of |option c|
|00003350| 68 61 72 61 63 74 65 72 | 73 2e 0a 0a 20 20 20 50 |haracter|s... P|
|00003360| 45 52 4d 55 54 45 20 69 | 73 20 74 68 65 20 64 65 |ERMUTE i|s the de|
|00003370| 66 61 75 6c 74 2e 20 20 | 57 65 20 70 65 72 6d 75 |fault. |We permu|
|00003380| 74 65 20 74 68 65 20 63 | 6f 6e 74 65 6e 74 73 20 |te the c|ontents |
|00003390| 6f 66 20 41 52 47 56 20 | 61 73 20 77 65 20 73 63 |of ARGV |as we sc|
|000033a0| 61 6e 2c 0a 20 20 20 73 | 6f 20 74 68 61 74 20 65 |an,. s|o that e|
|000033b0| 76 65 6e 74 75 61 6c 6c | 79 20 61 6c 6c 20 74 68 |ventuall|y all th|
|000033c0| 65 20 6e 6f 6e 2d 6f 70 | 74 69 6f 6e 73 20 61 72 |e non-op|tions ar|
|000033d0| 65 20 61 74 20 74 68 65 | 20 65 6e 64 2e 20 20 54 |e at the| end. T|
|000033e0| 68 69 73 20 61 6c 6c 6f | 77 73 20 6f 70 74 69 6f |his allo|ws optio|
|000033f0| 6e 73 0a 20 20 20 74 6f | 20 62 65 20 67 69 76 65 |ns. to| be give|
|00003400| 6e 20 69 6e 20 61 6e 79 | 20 6f 72 64 65 72 2c 20 |n in any| order, |
|00003410| 65 76 65 6e 20 77 69 74 | 68 20 70 72 6f 67 72 61 |even wit|h progra|
|00003420| 6d 73 20 74 68 61 74 20 | 77 65 72 65 20 6e 6f 74 |ms that |were not|
|00003430| 20 77 72 69 74 74 65 6e | 20 74 6f 0a 20 20 20 65 | written| to. e|
|00003440| 78 70 65 63 74 20 74 68 | 69 73 2e 0a 0a 20 20 20 |xpect th|is... |
|00003450| 52 45 54 55 52 4e 5f 49 | 4e 5f 4f 52 44 45 52 20 |RETURN_I|N_ORDER |
|00003460| 69 73 20 61 6e 20 6f 70 | 74 69 6f 6e 20 61 76 61 |is an op|tion ava|
|00003470| 69 6c 61 62 6c 65 20 74 | 6f 20 70 72 6f 67 72 61 |ilable t|o progra|
|00003480| 6d 73 20 74 68 61 74 20 | 77 65 72 65 20 77 72 69 |ms that |were wri|
|00003490| 74 74 65 6e 0a 20 20 20 | 74 6f 20 65 78 70 65 63 |tten. |to expec|
|000034a0| 74 20 6f 70 74 69 6f 6e | 73 20 61 6e 64 20 6f 74 |t option|s and ot|
|000034b0| 68 65 72 20 41 52 47 56 | 2d 65 6c 65 6d 65 6e 74 |her ARGV|-element|
|000034c0| 73 20 69 6e 20 61 6e 79 | 20 6f 72 64 65 72 20 61 |s in any| order a|
|000034d0| 6e 64 20 74 68 61 74 20 | 63 61 72 65 20 61 62 6f |nd that |care abo|
|000034e0| 75 74 0a 20 20 20 74 68 | 65 20 6f 72 64 65 72 69 |ut. th|e orderi|
|000034f0| 6e 67 20 6f 66 20 74 68 | 65 20 74 77 6f 2e 20 20 |ng of th|e two. |
|00003500| 57 65 20 64 65 73 63 72 | 69 62 65 20 65 61 63 68 |We descr|ibe each|
|00003510| 20 6e 6f 6e 2d 6f 70 74 | 69 6f 6e 20 41 52 47 56 | non-opt|ion ARGV|
|00003520| 2d 65 6c 65 6d 65 6e 74 | 0a 20 20 20 61 73 20 69 |-element|. as i|
|00003530| 66 20 69 74 20 77 65 72 | 65 20 74 68 65 20 61 72 |f it wer|e the ar|
|00003540| 67 75 6d 65 6e 74 20 6f | 66 20 61 6e 20 6f 70 74 |gument o|f an opt|
|00003550| 69 6f 6e 20 77 69 74 68 | 20 63 68 61 72 61 63 74 |ion with| charact|
|00003560| 65 72 20 63 6f 64 65 20 | 31 2e 0a 20 20 20 55 73 |er code |1.. Us|
|00003570| 69 6e 67 20 60 2d 27 20 | 61 73 20 74 68 65 20 66 |ing `-' |as the f|
|00003580| 69 72 73 74 20 63 68 61 | 72 61 63 74 65 72 20 6f |irst cha|racter o|
|00003590| 66 20 74 68 65 20 6c 69 | 73 74 20 6f 66 20 6f 70 |f the li|st of op|
|000035a0| 74 69 6f 6e 20 63 68 61 | 72 61 63 74 65 72 73 0a |tion cha|racters.|
|000035b0| 20 20 20 73 65 6c 65 63 | 74 73 20 74 68 69 73 20 | selec|ts this |
|000035c0| 6d 6f 64 65 20 6f 66 20 | 6f 70 65 72 61 74 69 6f |mode of |operatio|
|000035d0| 6e 2e 0a 0a 20 20 20 54 | 68 65 20 73 70 65 63 69 |n... T|he speci|
|000035e0| 61 6c 20 61 72 67 75 6d | 65 6e 74 20 60 2d 2d 27 |al argum|ent `--'|
|000035f0| 20 66 6f 72 63 65 73 20 | 61 6e 20 65 6e 64 20 6f | forces |an end o|
|00003600| 66 20 6f 70 74 69 6f 6e | 2d 73 63 61 6e 6e 69 6e |f option|-scannin|
|00003610| 67 20 72 65 67 61 72 64 | 6c 65 73 73 0a 20 20 20 |g regard|less. |
|00003620| 6f 66 20 74 68 65 20 76 | 61 6c 75 65 20 6f 66 20 |of the v|alue of |
|00003630| 60 6f 72 64 65 72 69 6e | 67 27 2e 20 20 49 6e 20 |`orderin|g'. In |
|00003640| 74 68 65 20 63 61 73 65 | 20 6f 66 20 52 45 54 55 |the case| of RETU|
|00003650| 52 4e 5f 49 4e 5f 4f 52 | 44 45 52 2c 20 6f 6e 6c |RN_IN_OR|DER, onl|
|00003660| 79 0a 20 20 20 60 2d 2d | 27 20 63 61 6e 20 63 61 |y. `--|' can ca|
|00003670| 75 73 65 20 60 67 65 74 | 6f 70 74 27 20 74 6f 20 |use `get|opt' to |
|00003680| 72 65 74 75 72 6e 20 45 | 4f 46 20 77 69 74 68 20 |return E|OF with |
|00003690| 60 6f 70 74 69 6e 64 27 | 20 21 3d 20 41 52 47 43 |`optind'| != ARGC|
|000036a0| 2e 20 20 2a 2f 0a 0a 73 | 74 61 74 69 63 20 65 6e |. */..s|tatic en|
|000036b0| 75 6d 0a 7b 0a 20 20 52 | 45 51 55 49 52 45 5f 4f |um.{. R|EQUIRE_O|
|000036c0| 52 44 45 52 2c 20 50 45 | 52 4d 55 54 45 2c 20 52 |RDER, PE|RMUTE, R|
|000036d0| 45 54 55 52 4e 5f 49 4e | 5f 4f 52 44 45 52 0a 7d |ETURN_IN|_ORDER.}|
|000036e0| 20 6f 72 64 65 72 69 6e | 67 3b 0a 0c 0a 23 69 66 | orderin|g;...#if|
|000036f0| 64 65 66 09 5f 5f 47 4e | 55 5f 4c 49 42 52 41 52 |def.__GN|U_LIBRAR|
|00003700| 59 5f 5f 0a 2f 2a 20 57 | 65 20 77 61 6e 74 20 74 |Y__./* W|e want t|
|00003710| 6f 20 61 76 6f 69 64 20 | 69 6e 63 6c 75 73 69 6f |o avoid |inclusio|
|00003720| 6e 20 6f 66 20 73 74 72 | 69 6e 67 2e 68 20 77 69 |n of str|ing.h wi|
|00003730| 74 68 20 6e 6f 6e 2d 47 | 4e 55 20 6c 69 62 72 61 |th non-G|NU libra|
|00003740| 72 69 65 73 0a 20 20 20 | 62 65 63 61 75 73 65 20 |ries. |because |
|00003750| 74 68 65 72 65 20 61 72 | 65 20 6d 61 6e 79 20 77 |there ar|e many w|
|00003760| 61 79 73 20 69 74 20 63 | 61 6e 20 63 61 75 73 65 |ays it c|an cause|
|00003770| 20 74 72 6f 75 62 6c 65 | 2e 0a 20 20 20 4f 6e 20 | trouble|.. On |
|00003780| 73 6f 6d 65 20 73 79 73 | 74 65 6d 73 2c 20 69 74 |some sys|tems, it|
|00003790| 20 63 6f 6e 74 61 69 6e | 73 20 73 70 65 63 69 61 | contain|s specia|
|000037a0| 6c 20 6d 61 67 69 63 20 | 6d 61 63 72 6f 73 20 74 |l magic |macros t|
|000037b0| 68 61 74 20 64 6f 6e 27 | 74 20 77 6f 72 6b 0a 20 |hat don'|t work. |
|000037c0| 20 20 69 6e 20 47 43 43 | 2e 20 20 2a 2f 0a 23 69 | in GCC|. */.#i|
|000037d0| 6e 63 6c 75 64 65 20 3c | 73 74 72 69 6e 67 2e 68 |nclude <|string.h|
|000037e0| 3e 0a 23 64 65 66 69 6e | 65 09 6d 79 5f 69 6e 64 |>.#defin|e.my_ind|
|000037f0| 65 78 09 73 74 72 63 68 | 72 0a 23 64 65 66 69 6e |ex.strch|r.#defin|
|00003800| 65 09 6d 79 5f 62 63 6f | 70 79 28 73 72 63 2c 20 |e.my_bco|py(src, |
|00003810| 64 73 74 2c 20 6e 29 09 | 6d 65 6d 63 70 79 20 28 |dst, n).|memcpy (|
|00003820| 28 64 73 74 29 2c 20 28 | 73 72 63 29 2c 20 28 6e |(dst), (|src), (n|
|00003830| 29 29 0a 23 65 6c 73 65 | 0a 0a 2f 2a 20 41 76 6f |)).#else|../* Avo|
|00003840| 69 64 20 64 65 70 65 6e | 64 69 6e 67 20 6f 6e 20 |id depen|ding on |
|00003850| 6c 69 62 72 61 72 79 20 | 66 75 6e 63 74 69 6f 6e |library |function|
|00003860| 73 20 6f 72 20 66 69 6c | 65 73 0a 20 20 20 77 68 |s or fil|es. wh|
|00003870| 6f 73 65 20 6e 61 6d 65 | 73 20 61 72 65 20 69 6e |ose name|s are in|
|00003880| 63 6f 6e 73 69 73 74 65 | 6e 74 2e 20 20 2a 2f 0a |consiste|nt. */.|
|00003890| 0a 63 68 61 72 20 2a 67 | 65 74 65 6e 76 20 28 29 |.char *g|etenv ()|
|000038a0| 3b 0a 0a 73 74 61 74 69 | 63 20 63 68 61 72 20 2a |;..stati|c char *|
|000038b0| 0a 6d 79 5f 69 6e 64 65 | 78 20 28 73 74 72 2c 20 |.my_inde|x (str, |
|000038c0| 63 68 72 29 0a 20 20 20 | 20 20 63 6f 6e 73 74 20 |chr). | const |
|000038d0| 63 68 61 72 20 2a 73 74 | 72 3b 0a 20 20 20 20 20 |char *st|r;. |
|000038e0| 69 6e 74 20 63 68 72 3b | 0a 7b 0a 20 20 77 68 69 |int chr;|.{. whi|
|000038f0| 6c 65 20 28 2a 73 74 72 | 29 0a 20 20 20 20 7b 0a |le (*str|). {.|
|00003900| 20 20 20 20 20 20 69 66 | 20 28 2a 73 74 72 20 3d | if| (*str =|
|00003910| 3d 20 63 68 72 29 0a 09 | 72 65 74 75 72 6e 20 28 |= chr)..|return (|
|00003920| 63 68 61 72 20 2a 29 20 | 73 74 72 3b 0a 20 20 20 |char *) |str;. |
|00003930| 20 20 20 73 74 72 2b 2b | 3b 0a 20 20 20 20 7d 0a | str++|;. }.|
|00003940| 20 20 72 65 74 75 72 6e | 20 30 3b 0a 7d 0a 0a 73 | return| 0;.}..s|
|00003950| 74 61 74 69 63 20 76 6f | 69 64 0a 6d 79 5f 62 63 |tatic vo|id.my_bc|
|00003960| 6f 70 79 20 28 66 72 6f | 6d 2c 20 74 6f 2c 20 73 |opy (fro|m, to, s|
|00003970| 69 7a 65 29 0a 20 20 20 | 20 20 63 6f 6e 73 74 20 |ize). | const |
|00003980| 63 68 61 72 20 2a 66 72 | 6f 6d 3b 0a 20 20 20 20 |char *fr|om;. |
|00003990| 20 63 68 61 72 20 2a 74 | 6f 3b 0a 20 20 20 20 20 | char *t|o;. |
|000039a0| 69 6e 74 20 73 69 7a 65 | 3b 0a 7b 0a 20 20 69 6e |int size|;.{. in|
|000039b0| 74 20 69 3b 0a 20 20 66 | 6f 72 20 28 69 20 3d 20 |t i;. f|or (i = |
|000039c0| 30 3b 20 69 20 3c 20 73 | 69 7a 65 3b 20 69 2b 2b |0; i < s|ize; i++|
|000039d0| 29 0a 20 20 20 20 74 6f | 5b 69 5d 20 3d 20 66 72 |). to|[i] = fr|
|000039e0| 6f 6d 5b 69 5d 3b 0a 7d | 0a 23 65 6e 64 69 66 09 |om[i];.}|.#endif.|
|000039f0| 09 09 09 2f 2a 20 47 4e | 55 20 43 20 6c 69 62 72 |.../* GN|U C libr|
|00003a00| 61 72 79 2e 20 20 2a 2f | 0a 0c 0a 2f 2a 20 48 61 |ary. */|.../* Ha|
|00003a10| 6e 64 6c 65 20 70 65 72 | 6d 75 74 61 74 69 6f 6e |ndle per|mutation|
|00003a20| 20 6f 66 20 61 72 67 75 | 6d 65 6e 74 73 2e 20 20 | of argu|ments. |
|00003a30| 2a 2f 0a 0a 2f 2a 20 44 | 65 73 63 72 69 62 65 20 |*/../* D|escribe |
|00003a40| 74 68 65 20 70 61 72 74 | 20 6f 66 20 41 52 47 56 |the part| of ARGV|
|00003a50| 20 74 68 61 74 20 63 6f | 6e 74 61 69 6e 73 20 6e | that co|ntains n|
|00003a60| 6f 6e 2d 6f 70 74 69 6f | 6e 73 20 74 68 61 74 20 |on-optio|ns that |
|00003a70| 68 61 76 65 0a 20 20 20 | 62 65 65 6e 20 73 6b 69 |have. |been ski|
|00003a80| 70 70 65 64 2e 20 20 60 | 66 69 72 73 74 5f 6e 6f |pped. `|first_no|
|00003a90| 6e 6f 70 74 27 20 69 73 | 20 74 68 65 20 69 6e 64 |nopt' is| the ind|
|00003aa0| 65 78 20 69 6e 20 41 52 | 47 56 20 6f 66 20 74 68 |ex in AR|GV of th|
|00003ab0| 65 20 66 69 72 73 74 20 | 6f 66 20 74 68 65 6d 3b |e first |of them;|
|00003ac0| 0a 20 20 20 60 6c 61 73 | 74 5f 6e 6f 6e 6f 70 74 |. `las|t_nonopt|
|00003ad0| 27 20 69 73 20 74 68 65 | 20 69 6e 64 65 78 20 61 |' is the| index a|
|00003ae0| 66 74 65 72 20 74 68 65 | 20 6c 61 73 74 20 6f 66 |fter the| last of|
|00003af0| 20 74 68 65 6d 2e 20 20 | 2a 2f 0a 0a 73 74 61 74 | them. |*/..stat|
|00003b00| 69 63 20 69 6e 74 20 66 | 69 72 73 74 5f 6e 6f 6e |ic int f|irst_non|
|00003b10| 6f 70 74 3b 0a 73 74 61 | 74 69 63 20 69 6e 74 20 |opt;.sta|tic int |
|00003b20| 6c 61 73 74 5f 6e 6f 6e | 6f 70 74 3b 0a 0a 2f 2a |last_non|opt;../*|
|00003b30| 20 45 78 63 68 61 6e 67 | 65 20 74 77 6f 20 61 64 | Exchang|e two ad|
|00003b40| 6a 61 63 65 6e 74 20 73 | 75 62 73 65 71 75 65 6e |jacent s|ubsequen|
|00003b50| 63 65 73 20 6f 66 20 41 | 52 47 56 2e 0a 20 20 20 |ces of A|RGV.. |
|00003b60| 4f 6e 65 20 73 75 62 73 | 65 71 75 65 6e 63 65 20 |One subs|equence |
|00003b70| 69 73 20 65 6c 65 6d 65 | 6e 74 73 20 5b 66 69 72 |is eleme|nts [fir|
|00003b80| 73 74 5f 6e 6f 6e 6f 70 | 74 2c 6c 61 73 74 5f 6e |st_nonop|t,last_n|
|00003b90| 6f 6e 6f 70 74 29 0a 20 | 20 20 77 68 69 63 68 20 |onopt). | which |
|00003ba0| 63 6f 6e 74 61 69 6e 73 | 20 61 6c 6c 20 74 68 65 |contains| all the|
|00003bb0| 20 6e 6f 6e 2d 6f 70 74 | 69 6f 6e 73 20 74 68 61 | non-opt|ions tha|
|00003bc0| 74 20 68 61 76 65 20 62 | 65 65 6e 20 73 6b 69 70 |t have b|een skip|
|00003bd0| 70 65 64 20 73 6f 20 66 | 61 72 2e 0a 20 20 20 54 |ped so f|ar.. T|
|00003be0| 68 65 20 6f 74 68 65 72 | 20 69 73 20 65 6c 65 6d |he other| is elem|
|00003bf0| 65 6e 74 73 20 5b 6c 61 | 73 74 5f 6e 6f 6e 6f 70 |ents [la|st_nonop|
|00003c00| 74 2c 6f 70 74 69 6e 64 | 29 2c 20 77 68 69 63 68 |t,optind|), which|
|00003c10| 20 63 6f 6e 74 61 69 6e | 73 20 61 6c 6c 0a 20 20 | contain|s all. |
|00003c20| 20 74 68 65 20 6f 70 74 | 69 6f 6e 73 20 70 72 6f | the opt|ions pro|
|00003c30| 63 65 73 73 65 64 20 73 | 69 6e 63 65 20 74 68 6f |cessed s|ince tho|
|00003c40| 73 65 20 6e 6f 6e 2d 6f | 70 74 69 6f 6e 73 20 77 |se non-o|ptions w|
|00003c50| 65 72 65 20 73 6b 69 70 | 70 65 64 2e 0a 0a 20 20 |ere skip|ped... |
|00003c60| 20 60 66 69 72 73 74 5f | 6e 6f 6e 6f 70 74 27 20 | `first_|nonopt' |
|00003c70| 61 6e 64 20 60 6c 61 73 | 74 5f 6e 6f 6e 6f 70 74 |and `las|t_nonopt|
|00003c80| 27 20 61 72 65 20 72 65 | 6c 6f 63 61 74 65 64 20 |' are re|located |
|00003c90| 73 6f 20 74 68 61 74 20 | 74 68 65 79 20 64 65 73 |so that |they des|
|00003ca0| 63 72 69 62 65 0a 20 20 | 20 74 68 65 20 6e 65 77 |cribe. | the new|
|00003cb0| 20 69 6e 64 69 63 65 73 | 20 6f 66 20 74 68 65 20 | indices| of the |
|00003cc0| 6e 6f 6e 2d 6f 70 74 69 | 6f 6e 73 20 69 6e 20 41 |non-opti|ons in A|
|00003cd0| 52 47 56 20 61 66 74 65 | 72 20 74 68 65 79 20 61 |RGV afte|r they a|
|00003ce0| 72 65 20 6d 6f 76 65 64 | 2e 20 20 2a 2f 0a 0a 73 |re moved|. */..s|
|00003cf0| 74 61 74 69 63 20 76 6f | 69 64 0a 65 78 63 68 61 |tatic vo|id.excha|
|00003d00| 6e 67 65 20 28 61 72 67 | 76 29 0a 20 20 20 20 20 |nge (arg|v). |
|00003d10| 63 68 61 72 20 2a 2a 61 | 72 67 76 3b 0a 7b 0a 20 |char **a|rgv;.{. |
|00003d20| 20 69 6e 74 20 6e 6f 6e | 6f 70 74 73 5f 73 69 7a | int non|opts_siz|
|00003d30| 65 20 3d 20 28 6c 61 73 | 74 5f 6e 6f 6e 6f 70 74 |e = (las|t_nonopt|
|00003d40| 20 2d 20 66 69 72 73 74 | 5f 6e 6f 6e 6f 70 74 29 | - first|_nonopt)|
|00003d50| 20 2a 20 73 69 7a 65 6f | 66 20 28 63 68 61 72 20 | * sizeo|f (char |
|00003d60| 2a 29 3b 0a 20 20 63 68 | 61 72 20 2a 2a 74 65 6d |*);. ch|ar **tem|
|00003d70| 70 20 3d 20 28 63 68 61 | 72 20 2a 2a 29 20 5f 5f |p = (cha|r **) __|
|00003d80| 61 6c 6c 6f 63 61 20 28 | 6e 6f 6e 6f 70 74 73 5f |alloca (|nonopts_|
|00003d90| 73 69 7a 65 29 3b 0a 0a | 20 20 2f 2a 20 49 6e 74 |size);..| /* Int|
|00003da0| 65 72 63 68 61 6e 67 65 | 20 74 68 65 20 74 77 6f |erchange| the two|
|00003db0| 20 62 6c 6f 63 6b 73 20 | 6f 66 20 64 61 74 61 20 | blocks |of data |
|00003dc0| 69 6e 20 41 52 47 56 2e | 20 20 2a 2f 0a 0a 20 20 |in ARGV.| */.. |
|00003dd0| 6d 79 5f 62 63 6f 70 79 | 20 28 28 63 68 61 72 20 |my_bcopy| ((char |
|00003de0| 2a 29 20 26 61 72 67 76 | 5b 66 69 72 73 74 5f 6e |*) &argv|[first_n|
|00003df0| 6f 6e 6f 70 74 5d 2c 20 | 28 63 68 61 72 20 2a 29 |onopt], |(char *)|
|00003e00| 20 74 65 6d 70 2c 20 6e | 6f 6e 6f 70 74 73 5f 73 | temp, n|onopts_s|
|00003e10| 69 7a 65 29 3b 0a 20 20 | 6d 79 5f 62 63 6f 70 79 |ize);. |my_bcopy|
|00003e20| 20 28 28 63 68 61 72 20 | 2a 29 20 26 61 72 67 76 | ((char |*) &argv|
|00003e30| 5b 6c 61 73 74 5f 6e 6f | 6e 6f 70 74 5d 2c 20 28 |[last_no|nopt], (|
|00003e40| 63 68 61 72 20 2a 29 20 | 26 61 72 67 76 5b 66 69 |char *) |&argv[fi|
|00003e50| 72 73 74 5f 6e 6f 6e 6f | 70 74 5d 2c 0a 09 20 20 |rst_nono|pt],.. |
|00003e60| 20 20 28 6f 70 74 69 6e | 64 20 2d 20 6c 61 73 74 | (optin|d - last|
|00003e70| 5f 6e 6f 6e 6f 70 74 29 | 20 2a 20 73 69 7a 65 6f |_nonopt)| * sizeo|
|00003e80| 66 20 28 63 68 61 72 20 | 2a 29 29 3b 0a 20 20 6d |f (char |*));. m|
|00003e90| 79 5f 62 63 6f 70 79 20 | 28 28 63 68 61 72 20 2a |y_bcopy |((char *|
|00003ea0| 29 20 74 65 6d 70 2c 0a | 09 20 20 20 20 28 63 68 |) temp,.|. (ch|
|00003eb0| 61 72 20 2a 29 20 26 61 | 72 67 76 5b 66 69 72 73 |ar *) &a|rgv[firs|
|00003ec0| 74 5f 6e 6f 6e 6f 70 74 | 20 2b 20 6f 70 74 69 6e |t_nonopt| + optin|
|00003ed0| 64 20 2d 20 6c 61 73 74 | 5f 6e 6f 6e 6f 70 74 5d |d - last|_nonopt]|
|00003ee0| 2c 0a 09 20 20 20 20 6e | 6f 6e 6f 70 74 73 5f 73 |,.. n|onopts_s|
|00003ef0| 69 7a 65 29 3b 0a 0a 20 | 20 2f 2a 20 55 70 64 61 |ize);.. | /* Upda|
|00003f00| 74 65 20 72 65 63 6f 72 | 64 73 20 66 6f 72 20 74 |te recor|ds for t|
|00003f10| 68 65 20 73 6c 6f 74 73 | 20 74 68 65 20 6e 6f 6e |he slots| the non|
|00003f20| 2d 6f 70 74 69 6f 6e 73 | 20 6e 6f 77 20 6f 63 63 |-options| now occ|
|00003f30| 75 70 79 2e 20 20 2a 2f | 0a 0a 20 20 66 69 72 73 |upy. */|.. firs|
|00003f40| 74 5f 6e 6f 6e 6f 70 74 | 20 2b 3d 20 28 6f 70 74 |t_nonopt| += (opt|
|00003f50| 69 6e 64 20 2d 20 6c 61 | 73 74 5f 6e 6f 6e 6f 70 |ind - la|st_nonop|
|00003f60| 74 29 3b 0a 20 20 6c 61 | 73 74 5f 6e 6f 6e 6f 70 |t);. la|st_nonop|
|00003f70| 74 20 3d 20 6f 70 74 69 | 6e 64 3b 0a 7d 0a 0c 0a |t = opti|nd;.}...|
|00003f80| 2f 2a 20 53 63 61 6e 20 | 65 6c 65 6d 65 6e 74 73 |/* Scan |elements|
|00003f90| 20 6f 66 20 41 52 47 56 | 20 28 77 68 6f 73 65 20 | of ARGV| (whose |
|00003fa0| 6c 65 6e 67 74 68 20 69 | 73 20 41 52 47 43 29 20 |length i|s ARGC) |
|00003fb0| 66 6f 72 20 6f 70 74 69 | 6f 6e 20 63 68 61 72 61 |for opti|on chara|
|00003fc0| 63 74 65 72 73 0a 20 20 | 20 67 69 76 65 6e 20 69 |cters. | given i|
|00003fd0| 6e 20 4f 50 54 53 54 52 | 49 4e 47 2e 0a 0a 20 20 |n OPTSTR|ING... |
|00003fe0| 20 49 66 20 61 6e 20 65 | 6c 65 6d 65 6e 74 20 6f | If an e|lement o|
|00003ff0| 66 20 41 52 47 56 20 73 | 74 61 72 74 73 20 77 69 |f ARGV s|tarts wi|
|00004000| 74 68 20 27 2d 27 2c 20 | 61 6e 64 20 69 73 20 6e |th '-', |and is n|
|00004010| 6f 74 20 65 78 61 63 74 | 6c 79 20 22 2d 22 20 6f |ot exact|ly "-" o|
|00004020| 72 20 22 2d 2d 22 2c 0a | 20 20 20 74 68 65 6e 20 |r "--",.| then |
|00004030| 69 74 20 69 73 20 61 6e | 20 6f 70 74 69 6f 6e 20 |it is an| option |
|00004040| 65 6c 65 6d 65 6e 74 2e | 20 20 54 68 65 20 63 68 |element.| The ch|
|00004050| 61 72 61 63 74 65 72 73 | 20 6f 66 20 74 68 69 73 |aracters| of this|
|00004060| 20 65 6c 65 6d 65 6e 74 | 0a 20 20 20 28 61 73 69 | element|. (asi|
|00004070| 64 65 20 66 72 6f 6d 20 | 74 68 65 20 69 6e 69 74 |de from |the init|
|00004080| 69 61 6c 20 27 2d 27 29 | 20 61 72 65 20 6f 70 74 |ial '-')| are opt|
|00004090| 69 6f 6e 20 63 68 61 72 | 61 63 74 65 72 73 2e 20 |ion char|acters. |
|000040a0| 20 49 66 20 60 67 65 74 | 6f 70 74 27 0a 20 20 20 | If `get|opt'. |
|000040b0| 69 73 20 63 61 6c 6c 65 | 64 20 72 65 70 65 61 74 |is calle|d repeat|
|000040c0| 65 64 6c 79 2c 20 69 74 | 20 72 65 74 75 72 6e 73 |edly, it| returns|
|000040d0| 20 73 75 63 63 65 73 73 | 69 76 65 6c 79 20 65 61 | success|ively ea|
|000040e0| 63 68 20 6f 66 20 74 68 | 65 20 6f 70 74 69 6f 6e |ch of th|e option|
|000040f0| 20 63 68 61 72 61 63 74 | 65 72 73 0a 20 20 20 66 | charact|ers. f|
|00004100| 72 6f 6d 20 65 61 63 68 | 20 6f 66 20 74 68 65 20 |rom each| of the |
|00004110| 6f 70 74 69 6f 6e 20 65 | 6c 65 6d 65 6e 74 73 2e |option e|lements.|
|00004120| 0a 0a 20 20 20 49 66 20 | 60 67 65 74 6f 70 74 27 |.. If |`getopt'|
|00004130| 20 66 69 6e 64 73 20 61 | 6e 6f 74 68 65 72 20 6f | finds a|nother o|
|00004140| 70 74 69 6f 6e 20 63 68 | 61 72 61 63 74 65 72 2c |ption ch|aracter,|
|00004150| 20 69 74 20 72 65 74 75 | 72 6e 73 20 74 68 61 74 | it retu|rns that|
|00004160| 20 63 68 61 72 61 63 74 | 65 72 2c 0a 20 20 20 75 | charact|er,. u|
|00004170| 70 64 61 74 69 6e 67 20 | 60 6f 70 74 69 6e 64 27 |pdating |`optind'|
|00004180| 20 61 6e 64 20 60 6e 65 | 78 74 63 68 61 72 27 20 | and `ne|xtchar' |
|00004190| 73 6f 20 74 68 61 74 20 | 74 68 65 20 6e 65 78 74 |so that |the next|
|000041a0| 20 63 61 6c 6c 20 74 6f | 20 60 67 65 74 6f 70 74 | call to| `getopt|
|000041b0| 27 20 63 61 6e 0a 20 20 | 20 72 65 73 75 6d 65 20 |' can. | resume |
|000041c0| 74 68 65 20 73 63 61 6e | 20 77 69 74 68 20 74 68 |the scan| with th|
|000041d0| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 6f 70 74 69 |e follow|ing opti|
|000041e0| 6f 6e 20 63 68 61 72 61 | 63 74 65 72 20 6f 72 20 |on chara|cter or |
|000041f0| 41 52 47 56 2d 65 6c 65 | 6d 65 6e 74 2e 0a 0a 20 |ARGV-ele|ment... |
|00004200| 20 20 49 66 20 74 68 65 | 72 65 20 61 72 65 20 6e | If the|re are n|
|00004210| 6f 20 6d 6f 72 65 20 6f | 70 74 69 6f 6e 20 63 68 |o more o|ption ch|
|00004220| 61 72 61 63 74 65 72 73 | 2c 20 60 67 65 74 6f 70 |aracters|, `getop|
|00004230| 74 27 20 72 65 74 75 72 | 6e 73 20 60 45 4f 46 27 |t' retur|ns `EOF'|
|00004240| 2e 0a 20 20 20 54 68 65 | 6e 20 60 6f 70 74 69 6e |.. The|n `optin|
|00004250| 64 27 20 69 73 20 74 68 | 65 20 69 6e 64 65 78 20 |d' is th|e index |
|00004260| 69 6e 20 41 52 47 56 20 | 6f 66 20 74 68 65 20 66 |in ARGV |of the f|
|00004270| 69 72 73 74 20 41 52 47 | 56 2d 65 6c 65 6d 65 6e |irst ARG|V-elemen|
|00004280| 74 0a 20 20 20 74 68 61 | 74 20 69 73 20 6e 6f 74 |t. tha|t is not|
|00004290| 20 61 6e 20 6f 70 74 69 | 6f 6e 2e 20 20 28 54 68 | an opti|on. (Th|
|000042a0| 65 20 41 52 47 56 2d 65 | 6c 65 6d 65 6e 74 73 20 |e ARGV-e|lements |
|000042b0| 68 61 76 65 20 62 65 65 | 6e 20 70 65 72 6d 75 74 |have bee|n permut|
|000042c0| 65 64 0a 20 20 20 73 6f | 20 74 68 61 74 20 74 68 |ed. so| that th|
|000042d0| 6f 73 65 20 74 68 61 74 | 20 61 72 65 20 6e 6f 74 |ose that| are not|
|000042e0| 20 6f 70 74 69 6f 6e 73 | 20 6e 6f 77 20 63 6f 6d | options| now com|
|000042f0| 65 20 6c 61 73 74 2e 29 | 0a 0a 20 20 20 4f 50 54 |e last.)|.. OPT|
|00004300| 53 54 52 49 4e 47 20 69 | 73 20 61 20 73 74 72 69 |STRING i|s a stri|
|00004310| 6e 67 20 63 6f 6e 74 61 | 69 6e 69 6e 67 20 74 68 |ng conta|ining th|
|00004320| 65 20 6c 65 67 69 74 69 | 6d 61 74 65 20 6f 70 74 |e legiti|mate opt|
|00004330| 69 6f 6e 20 63 68 61 72 | 61 63 74 65 72 73 2e 0a |ion char|acters..|
|00004340| 20 20 20 49 66 20 61 6e | 20 6f 70 74 69 6f 6e 20 | If an| option |
|00004350| 63 68 61 72 61 63 74 65 | 72 20 69 73 20 73 65 65 |characte|r is see|
|00004360| 6e 20 74 68 61 74 20 69 | 73 20 6e 6f 74 20 6c 69 |n that i|s not li|
|00004370| 73 74 65 64 20 69 6e 20 | 4f 50 54 53 54 52 49 4e |sted in |OPTSTRIN|
|00004380| 47 2c 0a 20 20 20 72 65 | 74 75 72 6e 20 27 3f 27 |G,. re|turn '?'|
|00004390| 20 61 66 74 65 72 20 70 | 72 69 6e 74 69 6e 67 20 | after p|rinting |
|000043a0| 61 6e 20 65 72 72 6f 72 | 20 6d 65 73 73 61 67 65 |an error| message|
|000043b0| 2e 20 20 49 66 20 79 6f | 75 20 73 65 74 20 60 6f |. If yo|u set `o|
|000043c0| 70 74 65 72 72 27 20 74 | 6f 0a 20 20 20 7a 65 72 |pterr' t|o. zer|
|000043d0| 6f 2c 20 74 68 65 20 65 | 72 72 6f 72 20 6d 65 73 |o, the e|rror mes|
|000043e0| 73 61 67 65 20 69 73 20 | 73 75 70 70 72 65 73 73 |sage is |suppress|
|000043f0| 65 64 20 62 75 74 20 77 | 65 20 73 74 69 6c 6c 20 |ed but w|e still |
|00004400| 72 65 74 75 72 6e 20 27 | 3f 27 2e 0a 0a 20 20 20 |return '|?'... |
|00004410| 49 66 20 61 20 63 68 61 | 72 20 69 6e 20 4f 50 54 |If a cha|r in OPT|
|00004420| 53 54 52 49 4e 47 20 69 | 73 20 66 6f 6c 6c 6f 77 |STRING i|s follow|
|00004430| 65 64 20 62 79 20 61 20 | 63 6f 6c 6f 6e 2c 20 74 |ed by a |colon, t|
|00004440| 68 61 74 20 6d 65 61 6e | 73 20 69 74 20 77 61 6e |hat mean|s it wan|
|00004450| 74 73 20 61 6e 20 61 72 | 67 2c 0a 20 20 20 73 6f |ts an ar|g,. so|
|00004460| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 74 | the fol|lowing t|
|00004470| 65 78 74 20 69 6e 20 74 | 68 65 20 73 61 6d 65 20 |ext in t|he same |
|00004480| 41 52 47 56 2d 65 6c 65 | 6d 65 6e 74 2c 20 6f 72 |ARGV-ele|ment, or|
|00004490| 20 74 68 65 20 74 65 78 | 74 20 6f 66 20 74 68 65 | the tex|t of the|
|000044a0| 20 66 6f 6c 6c 6f 77 69 | 6e 67 0a 20 20 20 41 52 | followi|ng. AR|
|000044b0| 47 56 2d 65 6c 65 6d 65 | 6e 74 2c 20 69 73 20 72 |GV-eleme|nt, is r|
|000044c0| 65 74 75 72 6e 65 64 20 | 69 6e 20 60 6f 70 74 61 |eturned |in `opta|
|000044d0| 72 67 27 2e 20 20 54 77 | 6f 20 63 6f 6c 6f 6e 73 |rg'. Tw|o colons|
|000044e0| 20 6d 65 61 6e 20 61 6e | 20 6f 70 74 69 6f 6e 20 | mean an| option |
|000044f0| 74 68 61 74 0a 20 20 20 | 77 61 6e 74 73 20 61 6e |that. |wants an|
|00004500| 20 6f 70 74 69 6f 6e 61 | 6c 20 61 72 67 3b 20 69 | optiona|l arg; i|
|00004510| 66 20 74 68 65 72 65 20 | 69 73 20 74 65 78 74 20 |f there |is text |
|00004520| 69 6e 20 74 68 65 20 63 | 75 72 72 65 6e 74 20 41 |in the c|urrent A|
|00004530| 52 47 56 2d 65 6c 65 6d | 65 6e 74 2c 0a 20 20 20 |RGV-elem|ent,. |
|00004540| 69 74 20 69 73 20 72 65 | 74 75 72 6e 65 64 20 69 |it is re|turned i|
|00004550| 6e 20 60 6f 70 74 61 72 | 67 27 2c 20 6f 74 68 65 |n `optar|g', othe|
|00004560| 72 77 69 73 65 20 60 6f | 70 74 61 72 67 27 20 69 |rwise `o|ptarg' i|
|00004570| 73 20 73 65 74 20 74 6f | 20 7a 65 72 6f 2e 0a 0a |s set to| zero...|
|00004580| 20 20 20 49 66 20 4f 50 | 54 53 54 52 49 4e 47 20 | If OP|TSTRING |
|00004590| 73 74 61 72 74 73 20 77 | 69 74 68 20 60 2d 27 20 |starts w|ith `-' |
|000045a0| 6f 72 20 60 2b 27 2c 20 | 69 74 20 72 65 71 75 65 |or `+', |it reque|
|000045b0| 73 74 73 20 64 69 66 66 | 65 72 65 6e 74 20 6d 65 |sts diff|erent me|
|000045c0| 74 68 6f 64 73 20 6f 66 | 0a 20 20 20 68 61 6e 64 |thods of|. hand|
|000045d0| 6c 69 6e 67 20 74 68 65 | 20 6e 6f 6e 2d 6f 70 74 |ling the| non-opt|
|000045e0| 69 6f 6e 20 41 52 47 56 | 2d 65 6c 65 6d 65 6e 74 |ion ARGV|-element|
|000045f0| 73 2e 0a 20 20 20 53 65 | 65 20 74 68 65 20 63 6f |s.. Se|e the co|
|00004600| 6d 6d 65 6e 74 73 20 61 | 62 6f 75 74 20 52 45 54 |mments a|bout RET|
|00004610| 55 52 4e 5f 49 4e 5f 4f | 52 44 45 52 20 61 6e 64 |URN_IN_O|RDER and|
|00004620| 20 52 45 51 55 49 52 45 | 5f 4f 52 44 45 52 2c 20 | REQUIRE|_ORDER, |
|00004630| 61 62 6f 76 65 2e 0a 0a | 20 20 20 4c 6f 6e 67 2d |above...| Long-|
|00004640| 6e 61 6d 65 64 20 6f 70 | 74 69 6f 6e 73 20 62 65 |named op|tions be|
|00004650| 67 69 6e 20 77 69 74 68 | 20 60 2d 2d 27 20 69 6e |gin with| `--' in|
|00004660| 73 74 65 61 64 20 6f 66 | 20 60 2d 27 2e 0a 20 20 |stead of| `-'.. |
|00004670| 20 54 68 65 69 72 20 6e | 61 6d 65 73 20 6d 61 79 | Their n|ames may|
|00004680| 20 62 65 20 61 62 62 72 | 65 76 69 61 74 65 64 20 | be abbr|eviated |
|00004690| 61 73 20 6c 6f 6e 67 20 | 61 73 20 74 68 65 20 61 |as long |as the a|
|000046a0| 62 62 72 65 76 69 61 74 | 69 6f 6e 20 69 73 20 75 |bbreviat|ion is u|
|000046b0| 6e 69 71 75 65 0a 20 20 | 20 6f 72 20 69 73 20 61 |nique. | or is a|
|000046c0| 6e 20 65 78 61 63 74 20 | 6d 61 74 63 68 20 66 6f |n exact |match fo|
|000046d0| 72 20 73 6f 6d 65 20 64 | 65 66 69 6e 65 64 20 6f |r some d|efined o|
|000046e0| 70 74 69 6f 6e 2e 20 20 | 49 66 20 74 68 65 79 20 |ption. |If they |
|000046f0| 68 61 76 65 20 61 6e 0a | 20 20 20 61 72 67 75 6d |have an.| argum|
|00004700| 65 6e 74 2c 20 69 74 20 | 66 6f 6c 6c 6f 77 73 20 |ent, it |follows |
|00004710| 74 68 65 20 6f 70 74 69 | 6f 6e 20 6e 61 6d 65 20 |the opti|on name |
|00004720| 69 6e 20 74 68 65 20 73 | 61 6d 65 20 41 52 47 56 |in the s|ame ARGV|
|00004730| 2d 65 6c 65 6d 65 6e 74 | 2c 20 73 65 70 61 72 61 |-element|, separa|
|00004740| 74 65 64 0a 20 20 20 66 | 72 6f 6d 20 74 68 65 20 |ted. f|rom the |
|00004750| 6f 70 74 69 6f 6e 20 6e | 61 6d 65 20 62 79 20 61 |option n|ame by a|
|00004760| 20 60 3d 27 2c 20 6f 72 | 20 65 6c 73 65 20 74 68 | `=', or| else th|
|00004770| 65 20 69 6e 20 6e 65 78 | 74 20 41 52 47 56 2d 65 |e in nex|t ARGV-e|
|00004780| 6c 65 6d 65 6e 74 2e 0a | 20 20 20 57 68 65 6e 20 |lement..| When |
|00004790| 60 67 65 74 6f 70 74 27 | 20 66 69 6e 64 73 20 61 |`getopt'| finds a|
|000047a0| 20 6c 6f 6e 67 2d 6e 61 | 6d 65 64 20 6f 70 74 69 | long-na|med opti|
|000047b0| 6f 6e 2c 20 69 74 20 72 | 65 74 75 72 6e 73 20 30 |on, it r|eturns 0|
|000047c0| 20 69 66 20 74 68 61 74 | 20 6f 70 74 69 6f 6e 27 | if that| option'|
|000047d0| 73 0a 20 20 20 60 66 6c | 61 67 27 20 66 69 65 6c |s. `fl|ag' fiel|
|000047e0| 64 20 69 73 20 6e 6f 6e | 7a 65 72 6f 2c 20 74 68 |d is non|zero, th|
|000047f0| 65 20 76 61 6c 75 65 20 | 6f 66 20 74 68 65 20 6f |e value |of the o|
|00004800| 70 74 69 6f 6e 27 73 20 | 60 76 61 6c 27 20 66 69 |ption's |`val' fi|
|00004810| 65 6c 64 0a 20 20 20 69 | 66 20 74 68 65 20 60 66 |eld. i|f the `f|
|00004820| 6c 61 67 27 20 66 69 65 | 6c 64 20 69 73 20 7a 65 |lag' fie|ld is ze|
|00004830| 72 6f 2e 0a 0a 20 20 20 | 54 68 65 20 65 6c 65 6d |ro... |The elem|
|00004840| 65 6e 74 73 20 6f 66 20 | 41 52 47 56 20 61 72 65 |ents of |ARGV are|
|00004850| 6e 27 74 20 72 65 61 6c | 6c 79 20 63 6f 6e 73 74 |n't real|ly const|
|00004860| 2c 20 62 65 63 61 75 73 | 65 20 77 65 20 70 65 72 |, becaus|e we per|
|00004870| 6d 75 74 65 20 74 68 65 | 6d 2e 0a 20 20 20 42 75 |mute the|m.. Bu|
|00004880| 74 20 77 65 20 70 72 65 | 74 65 6e 64 20 74 68 65 |t we pre|tend the|
|00004890| 79 27 72 65 20 63 6f 6e | 73 74 20 69 6e 20 74 68 |y're con|st in th|
|000048a0| 65 20 70 72 6f 74 6f 74 | 79 70 65 20 74 6f 20 62 |e protot|ype to b|
|000048b0| 65 20 63 6f 6d 70 61 74 | 69 62 6c 65 0a 20 20 20 |e compat|ible. |
|000048c0| 77 69 74 68 20 6f 74 68 | 65 72 20 73 79 73 74 65 |with oth|er syste|
|000048d0| 6d 73 2e 0a 0a 20 20 20 | 4c 4f 4e 47 4f 50 54 53 |ms... |LONGOPTS|
|000048e0| 20 69 73 20 61 20 76 65 | 63 74 6f 72 20 6f 66 20 | is a ve|ctor of |
|000048f0| 60 73 74 72 75 63 74 20 | 6f 70 74 69 6f 6e 27 20 |`struct |option' |
|00004900| 74 65 72 6d 69 6e 61 74 | 65 64 20 62 79 20 61 6e |terminat|ed by an|
|00004910| 0a 20 20 20 65 6c 65 6d | 65 6e 74 20 63 6f 6e 74 |. elem|ent cont|
|00004920| 61 69 6e 69 6e 67 20 61 | 20 6e 61 6d 65 20 77 68 |aining a| name wh|
|00004930| 69 63 68 20 69 73 20 7a | 65 72 6f 2e 0a 0a 20 20 |ich is z|ero... |
|00004940| 20 4c 4f 4e 47 49 4e 44 | 20 72 65 74 75 72 6e 73 | LONGIND| returns|
|00004950| 20 74 68 65 20 69 6e 64 | 65 78 20 69 6e 20 4c 4f | the ind|ex in LO|
|00004960| 4e 47 4f 50 54 20 6f 66 | 20 74 68 65 20 6c 6f 6e |NGOPT of| the lon|
|00004970| 67 2d 6e 61 6d 65 64 20 | 6f 70 74 69 6f 6e 20 66 |g-named |option f|
|00004980| 6f 75 6e 64 2e 0a 20 20 | 20 49 74 20 69 73 20 6f |ound.. | It is o|
|00004990| 6e 6c 79 20 76 61 6c 69 | 64 20 77 68 65 6e 20 61 |nly vali|d when a|
|000049a0| 20 6c 6f 6e 67 2d 6e 61 | 6d 65 64 20 6f 70 74 69 | long-na|med opti|
|000049b0| 6f 6e 20 68 61 73 20 62 | 65 65 6e 20 66 6f 75 6e |on has b|een foun|
|000049c0| 64 20 62 79 20 74 68 65 | 20 6d 6f 73 74 0a 20 20 |d by the| most. |
|000049d0| 20 72 65 63 65 6e 74 20 | 63 61 6c 6c 2e 0a 0a 20 | recent |call... |
|000049e0| 20 20 49 66 20 4c 4f 4e | 47 5f 4f 4e 4c 59 20 69 | If LON|G_ONLY i|
|000049f0| 73 20 6e 6f 6e 7a 65 72 | 6f 2c 20 27 2d 27 20 61 |s nonzer|o, '-' a|
|00004a00| 73 20 77 65 6c 6c 20 61 | 73 20 27 2d 2d 27 20 63 |s well a|s '--' c|
|00004a10| 61 6e 20 69 6e 74 72 6f | 64 75 63 65 0a 20 20 20 |an intro|duce. |
|00004a20| 6c 6f 6e 67 2d 6e 61 6d | 65 64 20 6f 70 74 69 6f |long-nam|ed optio|
|00004a30| 6e 73 2e 20 20 2a 2f 0a | 0a 69 6e 74 0a 5f 67 65 |ns. */.|.int._ge|
|00004a40| 74 6f 70 74 5f 69 6e 74 | 65 72 6e 61 6c 20 28 61 |topt_int|ernal (a|
|00004a50| 72 67 63 2c 20 61 72 67 | 76 2c 20 6f 70 74 73 74 |rgc, arg|v, optst|
|00004a60| 72 69 6e 67 2c 20 6c 6f | 6e 67 6f 70 74 73 2c 20 |ring, lo|ngopts, |
|00004a70| 6c 6f 6e 67 69 6e 64 2c | 20 6c 6f 6e 67 5f 6f 6e |longind,| long_on|
|00004a80| 6c 79 29 0a 20 20 20 20 | 20 69 6e 74 20 61 72 67 |ly). | int arg|
|00004a90| 63 3b 0a 20 20 20 20 20 | 63 68 61 72 20 2a 63 6f |c;. |char *co|
|00004aa0| 6e 73 74 20 2a 61 72 67 | 76 3b 0a 20 20 20 20 20 |nst *arg|v;. |
|00004ab0| 63 6f 6e 73 74 20 63 68 | 61 72 20 2a 6f 70 74 73 |const ch|ar *opts|
|00004ac0| 74 72 69 6e 67 3b 0a 20 | 20 20 20 20 63 6f 6e 73 |tring;. | cons|
|00004ad0| 74 20 73 74 72 75 63 74 | 20 6f 70 74 69 6f 6e 20 |t struct| option |
|00004ae0| 2a 6c 6f 6e 67 6f 70 74 | 73 3b 0a 20 20 20 20 20 |*longopt|s;. |
|00004af0| 69 6e 74 20 2a 6c 6f 6e | 67 69 6e 64 3b 0a 20 20 |int *lon|gind;. |
|00004b00| 20 20 20 69 6e 74 20 6c | 6f 6e 67 5f 6f 6e 6c 79 | int l|ong_only|
|00004b10| 3b 0a 7b 0a 20 20 69 6e | 74 20 6f 70 74 69 6f 6e |;.{. in|t option|
|00004b20| 5f 69 6e 64 65 78 3b 0a | 0a 20 20 6f 70 74 61 72 |_index;.|. optar|
|00004b30| 67 20 3d 20 30 3b 0a 0a | 20 20 2f 2a 20 49 6e 69 |g = 0;..| /* Ini|
|00004b40| 74 69 61 6c 69 7a 65 20 | 74 68 65 20 69 6e 74 65 |tialize |the inte|
|00004b50| 72 6e 61 6c 20 64 61 74 | 61 20 77 68 65 6e 20 74 |rnal dat|a when t|
|00004b60| 68 65 20 66 69 72 73 74 | 20 63 61 6c 6c 20 69 73 |he first| call is|
|00004b70| 20 6d 61 64 65 2e 0a 20 | 20 20 20 20 53 74 61 72 | made.. | Star|
|00004b80| 74 20 70 72 6f 63 65 73 | 73 69 6e 67 20 6f 70 74 |t proces|sing opt|
|00004b90| 69 6f 6e 73 20 77 69 74 | 68 20 41 52 47 56 2d 65 |ions wit|h ARGV-e|
|00004ba0| 6c 65 6d 65 6e 74 20 31 | 20 28 73 69 6e 63 65 20 |lement 1| (since |
|00004bb0| 41 52 47 56 2d 65 6c 65 | 6d 65 6e 74 20 30 0a 20 |ARGV-ele|ment 0. |
|00004bc0| 20 20 20 20 69 73 20 74 | 68 65 20 70 72 6f 67 72 | is t|he progr|
|00004bd0| 61 6d 20 6e 61 6d 65 29 | 3b 20 74 68 65 20 73 65 |am name)|; the se|
|00004be0| 71 75 65 6e 63 65 20 6f | 66 20 70 72 65 76 69 6f |quence o|f previo|
|00004bf0| 75 73 6c 79 20 73 6b 69 | 70 70 65 64 0a 20 20 20 |usly ski|pped. |
|00004c00| 20 20 6e 6f 6e 2d 6f 70 | 74 69 6f 6e 20 41 52 47 | non-op|tion ARG|
|00004c10| 56 2d 65 6c 65 6d 65 6e | 74 73 20 69 73 20 65 6d |V-elemen|ts is em|
|00004c20| 70 74 79 2e 20 20 2a 2f | 0a 0a 20 20 69 66 20 28 |pty. */|.. if (|
|00004c30| 6f 70 74 69 6e 64 20 3d | 3d 20 30 29 0a 20 20 20 |optind =|= 0). |
|00004c40| 20 7b 0a 20 20 20 20 20 | 20 66 69 72 73 74 5f 6e | {. | first_n|
|00004c50| 6f 6e 6f 70 74 20 3d 20 | 6c 61 73 74 5f 6e 6f 6e |onopt = |last_non|
|00004c60| 6f 70 74 20 3d 20 6f 70 | 74 69 6e 64 20 3d 20 31 |opt = op|tind = 1|
|00004c70| 3b 0a 0a 20 20 20 20 20 | 20 6e 65 78 74 63 68 61 |;.. | nextcha|
|00004c80| 72 20 3d 20 4e 55 4c 4c | 3b 0a 0a 20 20 20 20 20 |r = NULL|;.. |
|00004c90| 20 2f 2a 20 44 65 74 65 | 72 6d 69 6e 65 20 68 6f | /* Dete|rmine ho|
|00004ca0| 77 20 74 6f 20 68 61 6e | 64 6c 65 20 74 68 65 20 |w to han|dle the |
|00004cb0| 6f 72 64 65 72 69 6e 67 | 20 6f 66 20 6f 70 74 69 |ordering| of opti|
|00004cc0| 6f 6e 73 20 61 6e 64 20 | 6e 6f 6e 6f 70 74 69 6f |ons and |nonoptio|
|00004cd0| 6e 73 2e 20 20 2a 2f 0a | 0a 20 20 20 20 20 20 69 |ns. */.|. i|
|00004ce0| 66 20 28 6f 70 74 73 74 | 72 69 6e 67 5b 30 5d 20 |f (optst|ring[0] |
|00004cf0| 3d 3d 20 27 2d 27 29 0a | 09 7b 0a 09 20 20 6f 72 |== '-').|.{.. or|
|00004d00| 64 65 72 69 6e 67 20 3d | 20 52 45 54 55 52 4e 5f |dering =| RETURN_|
|00004d10| 49 4e 5f 4f 52 44 45 52 | 3b 0a 09 20 20 2b 2b 6f |IN_ORDER|;.. ++o|
|00004d20| 70 74 73 74 72 69 6e 67 | 3b 0a 09 7d 0a 20 20 20 |ptstring|;..}. |
|00004d30| 20 20 20 65 6c 73 65 20 | 69 66 20 28 6f 70 74 73 | else |if (opts|
|00004d40| 74 72 69 6e 67 5b 30 5d | 20 3d 3d 20 27 2b 27 29 |tring[0]| == '+')|
|00004d50| 0a 09 7b 0a 09 20 20 6f | 72 64 65 72 69 6e 67 20 |..{.. o|rdering |
|00004d60| 3d 20 52 45 51 55 49 52 | 45 5f 4f 52 44 45 52 3b |= REQUIR|E_ORDER;|
|00004d70| 0a 09 20 20 2b 2b 6f 70 | 74 73 74 72 69 6e 67 3b |.. ++op|tstring;|
|00004d80| 0a 09 7d 0a 20 20 20 20 | 20 20 65 6c 73 65 20 69 |..}. | else i|
|00004d90| 66 20 28 67 65 74 65 6e | 76 20 28 22 50 4f 53 49 |f (geten|v ("POSI|
|00004da0| 58 4c 59 5f 43 4f 52 52 | 45 43 54 22 29 20 21 3d |XLY_CORR|ECT") !=|
|00004db0| 20 4e 55 4c 4c 29 0a 09 | 6f 72 64 65 72 69 6e 67 | NULL)..|ordering|
|00004dc0| 20 3d 20 52 45 51 55 49 | 52 45 5f 4f 52 44 45 52 | = REQUI|RE_ORDER|
|00004dd0| 3b 0a 20 20 20 20 20 20 | 65 6c 73 65 0a 09 6f 72 |;. |else..or|
|00004de0| 64 65 72 69 6e 67 20 3d | 20 50 45 52 4d 55 54 45 |dering =| PERMUTE|
|00004df0| 3b 0a 20 20 20 20 7d 0a | 0a 20 20 69 66 20 28 6e |;. }.|. if (n|
|00004e00| 65 78 74 63 68 61 72 20 | 3d 3d 20 4e 55 4c 4c 20 |extchar |== NULL |
|00004e10| 7c 7c 20 2a 6e 65 78 74 | 63 68 61 72 20 3d 3d 20 ||| *next|char == |
|00004e20| 27 5c 30 27 29 0a 20 20 | 20 20 7b 0a 20 20 20 20 |'\0'). | {. |
|00004e30| 20 20 69 66 20 28 6f 72 | 64 65 72 69 6e 67 20 3d | if (or|dering =|
|00004e40| 3d 20 50 45 52 4d 55 54 | 45 29 0a 09 7b 0a 09 20 |= PERMUT|E)..{.. |
|00004e50| 20 2f 2a 20 49 66 20 77 | 65 20 68 61 76 65 20 6a | /* If w|e have j|
|00004e60| 75 73 74 20 70 72 6f 63 | 65 73 73 65 64 20 73 6f |ust proc|essed so|
|00004e70| 6d 65 20 6f 70 74 69 6f | 6e 73 20 66 6f 6c 6c 6f |me optio|ns follo|
|00004e80| 77 69 6e 67 20 73 6f 6d | 65 20 6e 6f 6e 2d 6f 70 |wing som|e non-op|
|00004e90| 74 69 6f 6e 73 2c 0a 09 | 20 20 20 20 20 65 78 63 |tions,..| exc|
|00004ea0| 68 61 6e 67 65 20 74 68 | 65 6d 20 73 6f 20 74 68 |hange th|em so th|
|00004eb0| 61 74 20 74 68 65 20 6f | 70 74 69 6f 6e 73 20 63 |at the o|ptions c|
|00004ec0| 6f 6d 65 20 66 69 72 73 | 74 2e 20 20 2a 2f 0a 0a |ome firs|t. */..|
|00004ed0| 09 20 20 69 66 20 28 66 | 69 72 73 74 5f 6e 6f 6e |. if (f|irst_non|
|00004ee0| 6f 70 74 20 21 3d 20 6c | 61 73 74 5f 6e 6f 6e 6f |opt != l|ast_nono|
|00004ef0| 70 74 20 26 26 20 6c 61 | 73 74 5f 6e 6f 6e 6f 70 |pt && la|st_nonop|
|00004f00| 74 20 21 3d 20 6f 70 74 | 69 6e 64 29 0a 09 20 20 |t != opt|ind).. |
|00004f10| 20 20 65 78 63 68 61 6e | 67 65 20 28 28 63 68 61 | exchan|ge ((cha|
|00004f20| 72 20 2a 2a 29 20 61 72 | 67 76 29 3b 0a 09 20 20 |r **) ar|gv);.. |
|00004f30| 65 6c 73 65 20 69 66 20 | 28 6c 61 73 74 5f 6e 6f |else if |(last_no|
|00004f40| 6e 6f 70 74 20 21 3d 20 | 6f 70 74 69 6e 64 29 0a |nopt != |optind).|
|00004f50| 09 20 20 20 20 66 69 72 | 73 74 5f 6e 6f 6e 6f 70 |. fir|st_nonop|
|00004f60| 74 20 3d 20 6f 70 74 69 | 6e 64 3b 0a 0a 09 20 20 |t = opti|nd;... |
|00004f70| 2f 2a 20 4e 6f 77 20 73 | 6b 69 70 20 61 6e 79 20 |/* Now s|kip any |
|00004f80| 61 64 64 69 74 69 6f 6e | 61 6c 20 6e 6f 6e 2d 6f |addition|al non-o|
|00004f90| 70 74 69 6f 6e 73 0a 09 | 20 20 20 20 20 61 6e 64 |ptions..| and|
|00004fa0| 20 65 78 74 65 6e 64 20 | 74 68 65 20 72 61 6e 67 | extend |the rang|
|00004fb0| 65 20 6f 66 20 6e 6f 6e | 2d 6f 70 74 69 6f 6e 73 |e of non|-options|
|00004fc0| 20 70 72 65 76 69 6f 75 | 73 6c 79 20 73 6b 69 70 | previou|sly skip|
|00004fd0| 70 65 64 2e 20 20 2a 2f | 0a 0a 09 20 20 77 68 69 |ped. */|... whi|
|00004fe0| 6c 65 20 28 6f 70 74 69 | 6e 64 20 3c 20 61 72 67 |le (opti|nd < arg|
|00004ff0| 63 0a 09 09 20 26 26 20 | 28 61 72 67 76 5b 6f 70 |c... && |(argv[op|
|00005000| 74 69 6e 64 5d 5b 30 5d | 20 21 3d 20 27 2d 27 20 |tind][0]| != '-' |
|00005010| 7c 7c 20 61 72 67 76 5b | 6f 70 74 69 6e 64 5d 5b ||| argv[|optind][|
|00005020| 31 5d 20 3d 3d 20 27 5c | 30 27 29 0a 23 69 66 64 |1] == '\|0').#ifd|
|00005030| 65 66 20 47 45 54 4f 50 | 54 5f 43 4f 4d 50 41 54 |ef GETOP|T_COMPAT|
|00005040| 0a 09 09 20 26 26 20 28 | 6c 6f 6e 67 6f 70 74 73 |... && (|longopts|
|00005050| 20 3d 3d 20 4e 55 4c 4c | 0a 09 09 20 20 20 20 20 | == NULL|... |
|00005060| 7c 7c 20 61 72 67 76 5b | 6f 70 74 69 6e 64 5d 5b ||| argv[|optind][|
|00005070| 30 5d 20 21 3d 20 27 2b | 27 20 7c 7c 20 61 72 67 |0] != '+|' || arg|
|00005080| 76 5b 6f 70 74 69 6e 64 | 5d 5b 31 5d 20 3d 3d 20 |v[optind|][1] == |
|00005090| 27 5c 30 27 29 0a 23 65 | 6e 64 69 66 09 09 09 09 |'\0').#e|ndif....|
|000050a0| 2f 2a 20 47 45 54 4f 50 | 54 5f 43 4f 4d 50 41 54 |/* GETOP|T_COMPAT|
|000050b0| 20 2a 2f 0a 09 09 20 29 | 0a 09 20 20 20 20 6f 70 | */... )|.. op|
|000050c0| 74 69 6e 64 2b 2b 3b 0a | 09 20 20 6c 61 73 74 5f |tind++;.|. last_|
|000050d0| 6e 6f 6e 6f 70 74 20 3d | 20 6f 70 74 69 6e 64 3b |nonopt =| optind;|
|000050e0| 0a 09 7d 0a 0a 20 20 20 | 20 20 20 2f 2a 20 53 70 |..}.. | /* Sp|
|000050f0| 65 63 69 61 6c 20 41 52 | 47 56 2d 65 6c 65 6d 65 |ecial AR|GV-eleme|
|00005100| 6e 74 20 60 2d 2d 27 20 | 6d 65 61 6e 73 20 70 72 |nt `--' |means pr|
|00005110| 65 6d 61 74 75 72 65 20 | 65 6e 64 20 6f 66 20 6f |emature |end of o|
|00005120| 70 74 69 6f 6e 73 2e 0a | 09 20 53 6b 69 70 20 69 |ptions..|. Skip i|
|00005130| 74 20 6c 69 6b 65 20 61 | 20 6e 75 6c 6c 20 6f 70 |t like a| null op|
|00005140| 74 69 6f 6e 2c 0a 09 20 | 74 68 65 6e 20 65 78 63 |tion,.. |then exc|
|00005150| 68 61 6e 67 65 20 77 69 | 74 68 20 70 72 65 76 69 |hange wi|th previ|
|00005160| 6f 75 73 20 6e 6f 6e 2d | 6f 70 74 69 6f 6e 73 20 |ous non-|options |
|00005170| 61 73 20 69 66 20 69 74 | 20 77 65 72 65 20 61 6e |as if it| were an|
|00005180| 20 6f 70 74 69 6f 6e 2c | 0a 09 20 74 68 65 6e 20 | option,|.. then |
|00005190| 73 6b 69 70 20 65 76 65 | 72 79 74 68 69 6e 67 20 |skip eve|rything |
|000051a0| 65 6c 73 65 20 6c 69 6b | 65 20 61 20 6e 6f 6e 2d |else lik|e a non-|
|000051b0| 6f 70 74 69 6f 6e 2e 20 | 20 2a 2f 0a 0a 20 20 20 |option. | */.. |
|000051c0| 20 20 20 69 66 20 28 6f | 70 74 69 6e 64 20 21 3d | if (o|ptind !=|
|000051d0| 20 61 72 67 63 20 26 26 | 20 21 73 74 72 63 6d 70 | argc &&| !strcmp|
|000051e0| 20 28 61 72 67 76 5b 6f | 70 74 69 6e 64 5d 2c 20 | (argv[o|ptind], |
|000051f0| 22 2d 2d 22 29 29 0a 09 | 7b 0a 09 20 20 6f 70 74 |"--"))..|{.. opt|
|00005200| 69 6e 64 2b 2b 3b 0a 0a | 09 20 20 69 66 20 28 66 |ind++;..|. if (f|
|00005210| 69 72 73 74 5f 6e 6f 6e | 6f 70 74 20 21 3d 20 6c |irst_non|opt != l|
|00005220| 61 73 74 5f 6e 6f 6e 6f | 70 74 20 26 26 20 6c 61 |ast_nono|pt && la|
|00005230| 73 74 5f 6e 6f 6e 6f 70 | 74 20 21 3d 20 6f 70 74 |st_nonop|t != opt|
|00005240| 69 6e 64 29 0a 09 20 20 | 20 20 65 78 63 68 61 6e |ind).. | exchan|
|00005250| 67 65 20 28 28 63 68 61 | 72 20 2a 2a 29 20 61 72 |ge ((cha|r **) ar|
|00005260| 67 76 29 3b 0a 09 20 20 | 65 6c 73 65 20 69 66 20 |gv);.. |else if |
|00005270| 28 66 69 72 73 74 5f 6e | 6f 6e 6f 70 74 20 3d 3d |(first_n|onopt ==|
|00005280| 20 6c 61 73 74 5f 6e 6f | 6e 6f 70 74 29 0a 09 20 | last_no|nopt).. |
|00005290| 20 20 20 66 69 72 73 74 | 5f 6e 6f 6e 6f 70 74 20 | first|_nonopt |
|000052a0| 3d 20 6f 70 74 69 6e 64 | 3b 0a 09 20 20 6c 61 73 |= optind|;.. las|
|000052b0| 74 5f 6e 6f 6e 6f 70 74 | 20 3d 20 61 72 67 63 3b |t_nonopt| = argc;|
|000052c0| 0a 0a 09 20 20 6f 70 74 | 69 6e 64 20 3d 20 61 72 |... opt|ind = ar|
|000052d0| 67 63 3b 0a 09 7d 0a 0a | 20 20 20 20 20 20 2f 2a |gc;..}..| /*|
|000052e0| 20 49 66 20 77 65 20 68 | 61 76 65 20 64 6f 6e 65 | If we h|ave done|
|000052f0| 20 61 6c 6c 20 74 68 65 | 20 41 52 47 56 2d 65 6c | all the| ARGV-el|
|00005300| 65 6d 65 6e 74 73 2c 20 | 73 74 6f 70 20 74 68 65 |ements, |stop the|
|00005310| 20 73 63 61 6e 0a 09 20 | 61 6e 64 20 62 61 63 6b | scan.. |and back|
|00005320| 20 6f 76 65 72 20 61 6e | 79 20 6e 6f 6e 2d 6f 70 | over an|y non-op|
|00005330| 74 69 6f 6e 73 20 74 68 | 61 74 20 77 65 20 73 6b |tions th|at we sk|
|00005340| 69 70 70 65 64 20 61 6e | 64 20 70 65 72 6d 75 74 |ipped an|d permut|
|00005350| 65 64 2e 20 20 2a 2f 0a | 0a 20 20 20 20 20 20 69 |ed. */.|. i|
|00005360| 66 20 28 6f 70 74 69 6e | 64 20 3d 3d 20 61 72 67 |f (optin|d == arg|
|00005370| 63 29 0a 09 7b 0a 09 20 | 20 2f 2a 20 53 65 74 20 |c)..{.. | /* Set |
|00005380| 74 68 65 20 6e 65 78 74 | 2d 61 72 67 2d 69 6e 64 |the next|-arg-ind|
|00005390| 65 78 20 74 6f 20 70 6f | 69 6e 74 20 61 74 20 74 |ex to po|int at t|
|000053a0| 68 65 20 6e 6f 6e 2d 6f | 70 74 69 6f 6e 73 0a 09 |he non-o|ptions..|
|000053b0| 20 20 20 20 20 74 68 61 | 74 20 77 65 20 70 72 65 | tha|t we pre|
|000053c0| 76 69 6f 75 73 6c 79 20 | 73 6b 69 70 70 65 64 2c |viously |skipped,|
|000053d0| 20 73 6f 20 74 68 65 20 | 63 61 6c 6c 65 72 20 77 | so the |caller w|
|000053e0| 69 6c 6c 20 64 69 67 65 | 73 74 20 74 68 65 6d 2e |ill dige|st them.|
|000053f0| 20 20 2a 2f 0a 09 20 20 | 69 66 20 28 66 69 72 73 | */.. |if (firs|
|00005400| 74 5f 6e 6f 6e 6f 70 74 | 20 21 3d 20 6c 61 73 74 |t_nonopt| != last|
|00005410| 5f 6e 6f 6e 6f 70 74 29 | 0a 09 20 20 20 20 6f 70 |_nonopt)|.. op|
|00005420| 74 69 6e 64 20 3d 20 66 | 69 72 73 74 5f 6e 6f 6e |tind = f|irst_non|
|00005430| 6f 70 74 3b 0a 09 20 20 | 72 65 74 75 72 6e 20 45 |opt;.. |return E|
|00005440| 4f 46 3b 0a 09 7d 0a 0a | 20 20 20 20 20 20 2f 2a |OF;..}..| /*|
|00005450| 20 49 66 20 77 65 20 68 | 61 76 65 20 63 6f 6d 65 | If we h|ave come|
|00005460| 20 74 6f 20 61 20 6e 6f | 6e 2d 6f 70 74 69 6f 6e | to a no|n-option|
|00005470| 20 61 6e 64 20 64 69 64 | 20 6e 6f 74 20 70 65 72 | and did| not per|
|00005480| 6d 75 74 65 20 69 74 2c | 0a 09 20 65 69 74 68 65 |mute it,|.. eithe|
|00005490| 72 20 73 74 6f 70 20 74 | 68 65 20 73 63 61 6e 20 |r stop t|he scan |
|000054a0| 6f 72 20 64 65 73 63 72 | 69 62 65 20 69 74 20 74 |or descr|ibe it t|
|000054b0| 6f 20 74 68 65 20 63 61 | 6c 6c 65 72 20 61 6e 64 |o the ca|ller and|
|000054c0| 20 70 61 73 73 20 69 74 | 20 62 79 2e 20 20 2a 2f | pass it| by. */|
|000054d0| 0a 0a 20 20 20 20 20 20 | 69 66 20 28 28 61 72 67 |.. |if ((arg|
|000054e0| 76 5b 6f 70 74 69 6e 64 | 5d 5b 30 5d 20 21 3d 20 |v[optind|][0] != |
|000054f0| 27 2d 27 20 7c 7c 20 61 | 72 67 76 5b 6f 70 74 69 |'-' || a|rgv[opti|
|00005500| 6e 64 5d 5b 31 5d 20 3d | 3d 20 27 5c 30 27 29 0a |nd][1] =|= '\0').|
|00005510| 23 69 66 64 65 66 20 47 | 45 54 4f 50 54 5f 43 4f |#ifdef G|ETOPT_CO|
|00005520| 4d 50 41 54 0a 09 20 20 | 26 26 20 28 6c 6f 6e 67 |MPAT.. |&& (long|
|00005530| 6f 70 74 73 20 3d 3d 20 | 4e 55 4c 4c 0a 09 20 20 |opts == |NULL.. |
|00005540| 20 20 20 20 7c 7c 20 61 | 72 67 76 5b 6f 70 74 69 | || a|rgv[opti|
|00005550| 6e 64 5d 5b 30 5d 20 21 | 3d 20 27 2b 27 20 7c 7c |nd][0] !|= '+' |||
|00005560| 20 61 72 67 76 5b 6f 70 | 74 69 6e 64 5d 5b 31 5d | argv[op|tind][1]|
|00005570| 20 3d 3d 20 27 5c 30 27 | 29 0a 23 65 6e 64 69 66 | == '\0'|).#endif|
|00005580| 09 09 09 09 2f 2a 20 47 | 45 54 4f 50 54 5f 43 4f |..../* G|ETOPT_CO|
|00005590| 4d 50 41 54 20 2a 2f 0a | 09 20 20 29 0a 09 7b 0a |MPAT */.|. )..{.|
|000055a0| 09 20 20 69 66 20 28 6f | 72 64 65 72 69 6e 67 20 |. if (o|rdering |
|000055b0| 3d 3d 20 52 45 51 55 49 | 52 45 5f 4f 52 44 45 52 |== REQUI|RE_ORDER|
|000055c0| 29 0a 09 20 20 20 20 72 | 65 74 75 72 6e 20 45 4f |).. r|eturn EO|
|000055d0| 46 3b 0a 09 20 20 6f 70 | 74 61 72 67 20 3d 20 61 |F;.. op|targ = a|
|000055e0| 72 67 76 5b 6f 70 74 69 | 6e 64 2b 2b 5d 3b 0a 09 |rgv[opti|nd++];..|
|000055f0| 20 20 72 65 74 75 72 6e | 20 31 3b 0a 09 7d 0a 0a | return| 1;..}..|
|00005600| 20 20 20 20 20 20 2f 2a | 20 57 65 20 68 61 76 65 | /*| We have|
|00005610| 20 66 6f 75 6e 64 20 61 | 6e 6f 74 68 65 72 20 6f | found a|nother o|
|00005620| 70 74 69 6f 6e 2d 41 52 | 47 56 2d 65 6c 65 6d 65 |ption-AR|GV-eleme|
|00005630| 6e 74 2e 0a 09 20 53 74 | 61 72 74 20 64 65 63 6f |nt... St|art deco|
|00005640| 64 69 6e 67 20 69 74 73 | 20 63 68 61 72 61 63 74 |ding its| charact|
|00005650| 65 72 73 2e 20 20 2a 2f | 0a 0a 20 20 20 20 20 20 |ers. */|.. |
|00005660| 6e 65 78 74 63 68 61 72 | 20 3d 20 28 61 72 67 76 |nextchar| = (argv|
|00005670| 5b 6f 70 74 69 6e 64 5d | 20 2b 20 31 0a 09 09 20 |[optind]| + 1... |
|00005680| 20 2b 20 28 6c 6f 6e 67 | 6f 70 74 73 20 21 3d 20 | + (long|opts != |
|00005690| 4e 55 4c 4c 20 26 26 20 | 61 72 67 76 5b 6f 70 74 |NULL && |argv[opt|
|000056a0| 69 6e 64 5d 5b 31 5d 20 | 3d 3d 20 27 2d 27 29 29 |ind][1] |== '-'))|
|000056b0| 3b 0a 20 20 20 20 7d 0a | 0a 20 20 69 66 20 28 6c |;. }.|. if (l|
|000056c0| 6f 6e 67 6f 70 74 73 20 | 21 3d 20 4e 55 4c 4c 0a |ongopts |!= NULL.|
|000056d0| 20 20 20 20 20 20 26 26 | 20 28 28 61 72 67 76 5b | &&| ((argv[|
|000056e0| 6f 70 74 69 6e 64 5d 5b | 30 5d 20 3d 3d 20 27 2d |optind][|0] == '-|
|000056f0| 27 0a 09 20 20 20 26 26 | 20 28 61 72 67 76 5b 6f |'.. &&| (argv[o|
|00005700| 70 74 69 6e 64 5d 5b 31 | 5d 20 3d 3d 20 27 2d 27 |ptind][1|] == '-'|
|00005710| 20 7c 7c 20 6c 6f 6e 67 | 5f 6f 6e 6c 79 29 29 0a | || long|_only)).|
|00005720| 23 69 66 64 65 66 20 47 | 45 54 4f 50 54 5f 43 4f |#ifdef G|ETOPT_CO|
|00005730| 4d 50 41 54 0a 09 20 20 | 7c 7c 20 61 72 67 76 5b |MPAT.. ||| argv[|
|00005740| 6f 70 74 69 6e 64 5d 5b | 30 5d 20 3d 3d 20 27 2b |optind][|0] == '+|
|00005750| 27 0a 23 65 6e 64 69 66 | 09 09 09 09 2f 2a 20 47 |'.#endif|..../* G|
|00005760| 45 54 4f 50 54 5f 43 4f | 4d 50 41 54 20 2a 2f 0a |ETOPT_CO|MPAT */.|
|00005770| 09 20 20 29 29 0a 20 20 | 20 20 7b 0a 20 20 20 20 |. )). | {. |
|00005780| 20 20 63 6f 6e 73 74 20 | 73 74 72 75 63 74 20 6f | const |struct o|
|00005790| 70 74 69 6f 6e 20 2a 70 | 3b 0a 20 20 20 20 20 20 |ption *p|;. |
|000057a0| 63 68 61 72 20 2a 73 20 | 3d 20 6e 65 78 74 63 68 |char *s |= nextch|
|000057b0| 61 72 3b 0a 20 20 20 20 | 20 20 69 6e 74 20 65 78 |ar;. | int ex|
|000057c0| 61 63 74 20 3d 20 30 3b | 0a 20 20 20 20 20 20 69 |act = 0;|. i|
|000057d0| 6e 74 20 61 6d 62 69 67 | 20 3d 20 30 3b 0a 20 20 |nt ambig| = 0;. |
|000057e0| 20 20 20 20 63 6f 6e 73 | 74 20 73 74 72 75 63 74 | cons|t struct|
|000057f0| 20 6f 70 74 69 6f 6e 20 | 2a 70 66 6f 75 6e 64 20 | option |*pfound |
|00005800| 3d 20 4e 55 4c 4c 3b 0a | 20 20 20 20 20 20 69 6e |= NULL;.| in|
|00005810| 74 20 69 6e 64 66 6f 75 | 6e 64 3b 0a 0a 20 20 20 |t indfou|nd;.. |
|00005820| 20 20 20 77 68 69 6c 65 | 20 28 2a 73 20 26 26 20 | while| (*s && |
|00005830| 2a 73 20 21 3d 20 27 3d | 27 29 0a 09 73 2b 2b 3b |*s != '=|')..s++;|
|00005840| 0a 0a 20 20 20 20 20 20 | 2f 2a 20 54 65 73 74 20 |.. |/* Test |
|00005850| 61 6c 6c 20 6f 70 74 69 | 6f 6e 73 20 66 6f 72 20 |all opti|ons for |
|00005860| 65 69 74 68 65 72 20 65 | 78 61 63 74 20 6d 61 74 |either e|xact mat|
|00005870| 63 68 20 6f 72 20 61 62 | 62 72 65 76 69 61 74 65 |ch or ab|breviate|
|00005880| 64 20 6d 61 74 63 68 65 | 73 2e 20 20 2a 2f 0a 20 |d matche|s. */. |
|00005890| 20 20 20 20 20 66 6f 72 | 20 28 70 20 3d 20 6c 6f | for| (p = lo|
|000058a0| 6e 67 6f 70 74 73 2c 20 | 6f 70 74 69 6f 6e 5f 69 |ngopts, |option_i|
|000058b0| 6e 64 65 78 20 3d 20 30 | 3b 20 70 2d 3e 6e 61 6d |ndex = 0|; p->nam|
|000058c0| 65 3b 0a 09 20 20 20 70 | 2b 2b 2c 20 6f 70 74 69 |e;.. p|++, opti|
|000058d0| 6f 6e 5f 69 6e 64 65 78 | 2b 2b 29 0a 09 69 66 20 |on_index|++)..if |
|000058e0| 28 21 73 74 72 6e 63 6d | 70 20 28 70 2d 3e 6e 61 |(!strncm|p (p->na|
|000058f0| 6d 65 2c 20 6e 65 78 74 | 63 68 61 72 2c 20 73 20 |me, next|char, s |
|00005900| 2d 20 6e 65 78 74 63 68 | 61 72 29 29 0a 09 20 20 |- nextch|ar)).. |
|00005910| 7b 0a 09 20 20 20 20 69 | 66 20 28 73 20 2d 20 6e |{.. i|f (s - n|
|00005920| 65 78 74 63 68 61 72 20 | 3d 3d 20 73 74 72 6c 65 |extchar |== strle|
|00005930| 6e 20 28 70 2d 3e 6e 61 | 6d 65 29 29 0a 09 20 20 |n (p->na|me)).. |
|00005940| 20 20 20 20 7b 0a 09 09 | 2f 2a 20 45 78 61 63 74 | {...|/* Exact|
|00005950| 20 6d 61 74 63 68 20 66 | 6f 75 6e 64 2e 20 20 2a | match f|ound. *|
|00005960| 2f 0a 09 09 70 66 6f 75 | 6e 64 20 3d 20 70 3b 0a |/...pfou|nd = p;.|
|00005970| 09 09 69 6e 64 66 6f 75 | 6e 64 20 3d 20 6f 70 74 |..indfou|nd = opt|
|00005980| 69 6f 6e 5f 69 6e 64 65 | 78 3b 0a 09 09 65 78 61 |ion_inde|x;...exa|
|00005990| 63 74 20 3d 20 31 3b 0a | 09 09 62 72 65 61 6b 3b |ct = 1;.|..break;|
|000059a0| 0a 09 20 20 20 20 20 20 | 7d 0a 09 20 20 20 20 65 |.. |}.. e|
|000059b0| 6c 73 65 20 69 66 20 28 | 70 66 6f 75 6e 64 20 3d |lse if (|pfound =|
|000059c0| 3d 20 4e 55 4c 4c 29 0a | 09 20 20 20 20 20 20 7b |= NULL).|. {|
|000059d0| 0a 09 09 2f 2a 20 46 69 | 72 73 74 20 6e 6f 6e 65 |.../* Fi|rst none|
|000059e0| 78 61 63 74 20 6d 61 74 | 63 68 20 66 6f 75 6e 64 |xact mat|ch found|
|000059f0| 2e 20 20 2a 2f 0a 09 09 | 70 66 6f 75 6e 64 20 3d |. */...|pfound =|
|00005a00| 20 70 3b 0a 09 09 69 6e | 64 66 6f 75 6e 64 20 3d | p;...in|dfound =|
|00005a10| 20 6f 70 74 69 6f 6e 5f | 69 6e 64 65 78 3b 0a 09 | option_|index;..|
|00005a20| 20 20 20 20 20 20 7d 0a | 09 20 20 20 20 65 6c 73 | }.|. els|
|00005a30| 65 0a 09 20 20 20 20 20 | 20 2f 2a 20 53 65 63 6f |e.. | /* Seco|
|00005a40| 6e 64 20 6e 6f 6e 65 78 | 61 63 74 20 6d 61 74 63 |nd nonex|act matc|
|00005a50| 68 20 66 6f 75 6e 64 2e | 20 20 2a 2f 0a 09 20 20 |h found.| */.. |
|00005a60| 20 20 20 20 61 6d 62 69 | 67 20 3d 20 31 3b 0a 09 | ambi|g = 1;..|
|00005a70| 20 20 7d 0a 0a 20 20 20 | 20 20 20 69 66 20 28 61 | }.. | if (a|
|00005a80| 6d 62 69 67 20 26 26 20 | 21 65 78 61 63 74 29 0a |mbig && |!exact).|
|00005a90| 09 7b 0a 09 20 20 69 66 | 20 28 6f 70 74 65 72 72 |.{.. if| (opterr|
|00005aa0| 29 0a 09 20 20 20 20 66 | 70 72 69 6e 74 66 20 28 |).. f|printf (|
|00005ab0| 73 74 64 65 72 72 2c 20 | 22 25 73 3a 20 6f 70 74 |stderr, |"%s: opt|
|00005ac0| 69 6f 6e 20 60 25 73 27 | 20 69 73 20 61 6d 62 69 |ion `%s'| is ambi|
|00005ad0| 67 75 6f 75 73 5c 6e 22 | 2c 0a 09 09 20 20 20 20 |guous\n"|,... |
|00005ae0| 20 61 72 67 76 5b 30 5d | 2c 20 61 72 67 76 5b 6f | argv[0]|, argv[o|
|00005af0| 70 74 69 6e 64 5d 29 3b | 0a 09 20 20 6e 65 78 74 |ptind]);|.. next|
|00005b00| 63 68 61 72 20 2b 3d 20 | 73 74 72 6c 65 6e 20 28 |char += |strlen (|
|00005b10| 6e 65 78 74 63 68 61 72 | 29 3b 0a 09 20 20 6f 70 |nextchar|);.. op|
|00005b20| 74 69 6e 64 2b 2b 3b 0a | 09 20 20 72 65 74 75 72 |tind++;.|. retur|
|00005b30| 6e 20 27 3f 27 3b 0a 09 | 7d 0a 0a 20 20 20 20 20 |n '?';..|}.. |
|00005b40| 20 69 66 20 28 70 66 6f | 75 6e 64 20 21 3d 20 4e | if (pfo|und != N|
|00005b50| 55 4c 4c 29 0a 09 7b 0a | 09 20 20 6f 70 74 69 6f |ULL)..{.|. optio|
|00005b60| 6e 5f 69 6e 64 65 78 20 | 3d 20 69 6e 64 66 6f 75 |n_index |= indfou|
|00005b70| 6e 64 3b 0a 09 20 20 6f | 70 74 69 6e 64 2b 2b 3b |nd;.. o|ptind++;|
|00005b80| 0a 09 20 20 69 66 20 28 | 2a 73 29 0a 09 20 20 20 |.. if (|*s).. |
|00005b90| 20 7b 0a 09 20 20 20 20 | 20 20 2f 2a 20 44 6f 6e | {.. | /* Don|
|00005ba0| 27 74 20 74 65 73 74 20 | 68 61 73 5f 61 72 67 20 |'t test |has_arg |
|00005bb0| 77 69 74 68 20 3e 2c 20 | 62 65 63 61 75 73 65 20 |with >, |because |
|00005bc0| 73 6f 6d 65 20 43 20 63 | 6f 6d 70 69 6c 65 72 73 |some C c|ompilers|
|00005bd0| 20 64 6f 6e 27 74 0a 09 | 09 20 61 6c 6c 6f 77 20 | don't..|. allow |
|00005be0| 69 74 20 74 6f 20 62 65 | 20 75 73 65 64 20 6f 6e |it to be| used on|
|00005bf0| 20 65 6e 75 6d 73 2e 20 | 20 2a 2f 0a 09 20 20 20 | enums. | */.. |
|00005c00| 20 20 20 69 66 20 28 70 | 66 6f 75 6e 64 2d 3e 68 | if (p|found->h|
|00005c10| 61 73 5f 61 72 67 29 0a | 09 09 6f 70 74 61 72 67 |as_arg).|..optarg|
|00005c20| 20 3d 20 73 20 2b 20 31 | 3b 0a 09 20 20 20 20 20 | = s + 1|;.. |
|00005c30| 20 65 6c 73 65 0a 09 09 | 7b 0a 09 09 20 20 69 66 | else...|{... if|
|00005c40| 20 28 6f 70 74 65 72 72 | 29 0a 09 09 20 20 20 20 | (opterr|)... |
|00005c50| 7b 0a 09 09 20 20 20 20 | 20 20 69 66 20 28 61 72 |{... | if (ar|
|00005c60| 67 76 5b 6f 70 74 69 6e | 64 20 2d 20 31 5d 5b 31 |gv[optin|d - 1][1|
|00005c70| 5d 20 3d 3d 20 27 2d 27 | 29 0a 09 09 09 2f 2a 20 |] == '-'|)..../* |
|00005c80| 2d 2d 6f 70 74 69 6f 6e | 20 2a 2f 0a 09 09 09 66 |--option| */....f|
|00005c90| 70 72 69 6e 74 66 20 28 | 73 74 64 65 72 72 2c 0a |printf (|stderr,.|
|00005ca0| 09 09 09 09 20 22 25 73 | 3a 20 6f 70 74 69 6f 6e |.... "%s|: option|
|00005cb0| 20 60 2d 2d 25 73 27 20 | 64 6f 65 73 6e 27 74 20 | `--%s' |doesn't |
|00005cc0| 61 6c 6c 6f 77 20 61 6e | 20 61 72 67 75 6d 65 6e |allow an| argumen|
|00005cd0| 74 5c 6e 22 2c 0a 09 09 | 09 09 20 61 72 67 76 5b |t\n",...|.. argv[|
|00005ce0| 30 5d 2c 20 70 66 6f 75 | 6e 64 2d 3e 6e 61 6d 65 |0], pfou|nd->name|
|00005cf0| 29 3b 0a 09 09 20 20 20 | 20 20 20 65 6c 73 65 0a |);... | else.|
|00005d00| 09 09 09 2f 2a 20 2b 6f | 70 74 69 6f 6e 20 6f 72 |.../* +o|ption or|
|00005d10| 20 2d 6f 70 74 69 6f 6e | 20 2a 2f 0a 09 09 09 66 | -option| */....f|
|00005d20| 70 72 69 6e 74 66 20 28 | 73 74 64 65 72 72 2c 0a |printf (|stderr,.|
|00005d30| 09 09 09 20 20 20 20 20 | 22 25 73 3a 20 6f 70 74 |... |"%s: opt|
|00005d40| 69 6f 6e 20 60 25 63 25 | 73 27 20 64 6f 65 73 6e |ion `%c%|s' doesn|
|00005d50| 27 74 20 61 6c 6c 6f 77 | 20 61 6e 20 61 72 67 75 |'t allow| an argu|
|00005d60| 6d 65 6e 74 5c 6e 22 2c | 0a 09 09 09 20 20 20 20 |ment\n",|.... |
|00005d70| 20 61 72 67 76 5b 30 5d | 2c 20 61 72 67 76 5b 6f | argv[0]|, argv[o|
|00005d80| 70 74 69 6e 64 20 2d 20 | 31 5d 5b 30 5d 2c 20 70 |ptind - |1][0], p|
|00005d90| 66 6f 75 6e 64 2d 3e 6e | 61 6d 65 29 3b 0a 09 09 |found->n|ame);...|
|00005da0| 20 20 20 20 7d 0a 09 09 | 20 20 6e 65 78 74 63 68 | }...| nextch|
|00005db0| 61 72 20 2b 3d 20 73 74 | 72 6c 65 6e 20 28 6e 65 |ar += st|rlen (ne|
|00005dc0| 78 74 63 68 61 72 29 3b | 0a 09 09 20 20 72 65 74 |xtchar);|... ret|
|00005dd0| 75 72 6e 20 27 3f 27 3b | 0a 09 09 7d 0a 09 20 20 |urn '?';|...}.. |
|00005de0| 20 20 7d 0a 09 20 20 65 | 6c 73 65 20 69 66 20 28 | }.. e|lse if (|
|00005df0| 70 66 6f 75 6e 64 2d 3e | 68 61 73 5f 61 72 67 20 |pfound->|has_arg |
|00005e00| 3d 3d 20 31 29 0a 09 20 | 20 20 20 7b 0a 09 20 20 |== 1).. | {.. |
|00005e10| 20 20 20 20 69 66 20 28 | 6f 70 74 69 6e 64 20 3c | if (|optind <|
|00005e20| 20 61 72 67 63 29 0a 09 | 09 6f 70 74 61 72 67 20 | argc)..|.optarg |
|00005e30| 3d 20 61 72 67 76 5b 6f | 70 74 69 6e 64 2b 2b 5d |= argv[o|ptind++]|
|00005e40| 3b 0a 09 20 20 20 20 20 | 20 65 6c 73 65 0a 09 09 |;.. | else...|
|00005e50| 7b 0a 09 09 20 20 69 66 | 20 28 6f 70 74 65 72 72 |{... if| (opterr|
|00005e60| 29 0a 09 09 20 20 20 20 | 66 70 72 69 6e 74 66 20 |)... |fprintf |
|00005e70| 28 73 74 64 65 72 72 2c | 20 22 25 73 3a 20 6f 70 |(stderr,| "%s: op|
|00005e80| 74 69 6f 6e 20 60 25 73 | 27 20 72 65 71 75 69 72 |tion `%s|' requir|
|00005e90| 65 73 20 61 6e 20 61 72 | 67 75 6d 65 6e 74 5c 6e |es an ar|gument\n|
|00005ea0| 22 2c 0a 09 09 09 20 20 | 20 20 20 61 72 67 76 5b |",.... | argv[|
|00005eb0| 30 5d 2c 20 61 72 67 76 | 5b 6f 70 74 69 6e 64 20 |0], argv|[optind |
|00005ec0| 2d 20 31 5d 29 3b 0a 09 | 09 20 20 6e 65 78 74 63 |- 1]);..|. nextc|
|00005ed0| 68 61 72 20 2b 3d 20 73 | 74 72 6c 65 6e 20 28 6e |har += s|trlen (n|
|00005ee0| 65 78 74 63 68 61 72 29 | 3b 0a 09 09 20 20 72 65 |extchar)|;... re|
|00005ef0| 74 75 72 6e 20 6f 70 74 | 73 74 72 69 6e 67 5b 30 |turn opt|string[0|
|00005f00| 5d 20 3d 3d 20 27 3a 27 | 20 3f 20 27 3a 27 20 3a |] == ':'| ? ':' :|
|00005f10| 20 27 3f 27 3b 0a 09 09 | 7d 0a 09 20 20 20 20 7d | '?';...|}.. }|
|00005f20| 0a 09 20 20 6e 65 78 74 | 63 68 61 72 20 2b 3d 20 |.. next|char += |
|00005f30| 73 74 72 6c 65 6e 20 28 | 6e 65 78 74 63 68 61 72 |strlen (|nextchar|
|00005f40| 29 3b 0a 09 20 20 69 66 | 20 28 6c 6f 6e 67 69 6e |);.. if| (longin|
|00005f50| 64 20 21 3d 20 4e 55 4c | 4c 29 0a 09 20 20 20 20 |d != NUL|L).. |
|00005f60| 2a 6c 6f 6e 67 69 6e 64 | 20 3d 20 6f 70 74 69 6f |*longind| = optio|
|00005f70| 6e 5f 69 6e 64 65 78 3b | 0a 09 20 20 69 66 20 28 |n_index;|.. if (|
|00005f80| 70 66 6f 75 6e 64 2d 3e | 66 6c 61 67 29 0a 09 20 |pfound->|flag).. |
|00005f90| 20 20 20 7b 0a 09 20 20 | 20 20 20 20 2a 28 70 66 | {.. | *(pf|
|00005fa0| 6f 75 6e 64 2d 3e 66 6c | 61 67 29 20 3d 20 70 66 |ound->fl|ag) = pf|
|00005fb0| 6f 75 6e 64 2d 3e 76 61 | 6c 3b 0a 09 20 20 20 20 |ound->va|l;.. |
|00005fc0| 20 20 72 65 74 75 72 6e | 20 30 3b 0a 09 20 20 20 | return| 0;.. |
|00005fd0| 20 7d 0a 09 20 20 72 65 | 74 75 72 6e 20 70 66 6f | }.. re|turn pfo|
|00005fe0| 75 6e 64 2d 3e 76 61 6c | 3b 0a 09 7d 0a 20 20 20 |und->val|;..}. |
|00005ff0| 20 20 20 2f 2a 20 43 61 | 6e 27 74 20 66 69 6e 64 | /* Ca|n't find|
|00006000| 20 69 74 20 61 73 20 61 | 20 6c 6f 6e 67 20 6f 70 | it as a| long op|
|00006010| 74 69 6f 6e 2e 20 20 49 | 66 20 74 68 69 73 20 69 |tion. I|f this i|
|00006020| 73 20 6e 6f 74 20 67 65 | 74 6f 70 74 5f 6c 6f 6e |s not ge|topt_lon|
|00006030| 67 5f 6f 6e 6c 79 2c 0a | 09 20 6f 72 20 74 68 65 |g_only,.|. or the|
|00006040| 20 6f 70 74 69 6f 6e 20 | 73 74 61 72 74 73 20 77 | option |starts w|
|00006050| 69 74 68 20 27 2d 2d 27 | 20 6f 72 20 69 73 20 6e |ith '--'| or is n|
|00006060| 6f 74 20 61 20 76 61 6c | 69 64 20 73 68 6f 72 74 |ot a val|id short|
|00006070| 0a 09 20 6f 70 74 69 6f | 6e 2c 20 74 68 65 6e 20 |.. optio|n, then |
|00006080| 69 74 27 73 20 61 6e 20 | 65 72 72 6f 72 2e 0a 09 |it's an |error...|
|00006090| 20 4f 74 68 65 72 77 69 | 73 65 20 69 6e 74 65 72 | Otherwi|se inter|
|000060a0| 70 72 65 74 20 69 74 20 | 61 73 20 61 20 73 68 6f |pret it |as a sho|
|000060b0| 72 74 20 6f 70 74 69 6f | 6e 2e 20 20 2a 2f 0a 20 |rt optio|n. */. |
|000060c0| 20 20 20 20 20 69 66 20 | 28 21 6c 6f 6e 67 5f 6f | if |(!long_o|
|000060d0| 6e 6c 79 20 7c 7c 20 61 | 72 67 76 5b 6f 70 74 69 |nly || a|rgv[opti|
|000060e0| 6e 64 5d 5b 31 5d 20 3d | 3d 20 27 2d 27 0a 23 69 |nd][1] =|= '-'.#i|
|000060f0| 66 64 65 66 20 47 45 54 | 4f 50 54 5f 43 4f 4d 50 |fdef GET|OPT_COMP|
|00006100| 41 54 0a 09 20 20 7c 7c | 20 61 72 67 76 5b 6f 70 |AT.. ||| argv[op|
|00006110| 74 69 6e 64 5d 5b 30 5d | 20 3d 3d 20 27 2b 27 0a |tind][0]| == '+'.|
|00006120| 23 65 6e 64 69 66 09 09 | 09 09 2f 2a 20 47 45 54 |#endif..|../* GET|
|00006130| 4f 50 54 5f 43 4f 4d 50 | 41 54 20 2a 2f 0a 09 20 |OPT_COMP|AT */.. |
|00006140| 20 7c 7c 20 6d 79 5f 69 | 6e 64 65 78 20 28 6f 70 | || my_i|ndex (op|
|00006150| 74 73 74 72 69 6e 67 2c | 20 2a 6e 65 78 74 63 68 |tstring,| *nextch|
|00006160| 61 72 29 20 3d 3d 20 4e | 55 4c 4c 29 0a 09 7b 0a |ar) == N|ULL)..{.|
|00006170| 09 20 20 69 66 20 28 6f | 70 74 65 72 72 29 0a 09 |. if (o|pterr)..|
|00006180| 20 20 20 20 7b 0a 09 20 | 20 20 20 20 20 69 66 20 | {.. | if |
|00006190| 28 61 72 67 76 5b 6f 70 | 74 69 6e 64 5d 5b 31 5d |(argv[op|tind][1]|
|000061a0| 20 3d 3d 20 27 2d 27 29 | 0a 09 09 2f 2a 20 2d 2d | == '-')|.../* --|
|000061b0| 6f 70 74 69 6f 6e 20 2a | 2f 0a 09 09 66 70 72 69 |option *|/...fpri|
|000061c0| 6e 74 66 20 28 73 74 64 | 65 72 72 2c 20 22 25 73 |ntf (std|err, "%s|
|000061d0| 3a 20 75 6e 72 65 63 6f | 67 6e 69 7a 65 64 20 6f |: unreco|gnized o|
|000061e0| 70 74 69 6f 6e 20 60 2d | 2d 25 73 27 5c 6e 22 2c |ption `-|-%s'\n",|
|000061f0| 0a 09 09 09 20 61 72 67 | 76 5b 30 5d 2c 20 6e 65 |.... arg|v[0], ne|
|00006200| 78 74 63 68 61 72 29 3b | 0a 09 20 20 20 20 20 20 |xtchar);|.. |
|00006210| 65 6c 73 65 0a 09 09 2f | 2a 20 2b 6f 70 74 69 6f |else.../|* +optio|
|00006220| 6e 20 6f 72 20 2d 6f 70 | 74 69 6f 6e 20 2a 2f 0a |n or -op|tion */.|
|00006230| 09 09 66 70 72 69 6e 74 | 66 20 28 73 74 64 65 72 |..fprint|f (stder|
|00006240| 72 2c 20 22 25 73 3a 20 | 75 6e 72 65 63 6f 67 6e |r, "%s: |unrecogn|
|00006250| 69 7a 65 64 20 6f 70 74 | 69 6f 6e 20 60 25 63 25 |ized opt|ion `%c%|
|00006260| 73 27 5c 6e 22 2c 0a 09 | 09 09 20 61 72 67 76 5b |s'\n",..|.. argv[|
|00006270| 30 5d 2c 20 61 72 67 76 | 5b 6f 70 74 69 6e 64 5d |0], argv|[optind]|
|00006280| 5b 30 5d 2c 20 6e 65 78 | 74 63 68 61 72 29 3b 0a |[0], nex|tchar);.|
|00006290| 09 20 20 20 20 7d 0a 09 | 20 20 6e 65 78 74 63 68 |. }..| nextch|
|000062a0| 61 72 20 3d 20 28 63 68 | 61 72 20 2a 29 20 22 22 |ar = (ch|ar *) ""|
|000062b0| 3b 0a 09 20 20 6f 70 74 | 69 6e 64 2b 2b 3b 0a 09 |;.. opt|ind++;..|
|000062c0| 20 20 72 65 74 75 72 6e | 20 27 3f 27 3b 0a 09 7d | return| '?';..}|
|000062d0| 0a 20 20 20 20 7d 0a 0a | 20 20 2f 2a 20 4c 6f 6f |. }..| /* Loo|
|000062e0| 6b 20 61 74 20 61 6e 64 | 20 68 61 6e 64 6c 65 20 |k at and| handle |
|000062f0| 74 68 65 20 6e 65 78 74 | 20 6f 70 74 69 6f 6e 2d |the next| option-|
|00006300| 63 68 61 72 61 63 74 65 | 72 2e 20 20 2a 2f 0a 0a |characte|r. */..|
|00006310| 20 20 7b 0a 20 20 20 20 | 63 68 61 72 20 63 20 3d | {. |char c =|
|00006320| 20 2a 6e 65 78 74 63 68 | 61 72 2b 2b 3b 0a 20 20 | *nextch|ar++;. |
|00006330| 20 20 63 68 61 72 20 2a | 74 65 6d 70 20 3d 20 6d | char *|temp = m|
|00006340| 79 5f 69 6e 64 65 78 20 | 28 6f 70 74 73 74 72 69 |y_index |(optstri|
|00006350| 6e 67 2c 20 63 29 3b 0a | 0a 20 20 20 20 2f 2a 20 |ng, c);.|. /* |
|00006360| 49 6e 63 72 65 6d 65 6e | 74 20 60 6f 70 74 69 6e |Incremen|t `optin|
|00006370| 64 27 20 77 68 65 6e 20 | 77 65 20 73 74 61 72 74 |d' when |we start|
|00006380| 20 74 6f 20 70 72 6f 63 | 65 73 73 20 69 74 73 20 | to proc|ess its |
|00006390| 6c 61 73 74 20 63 68 61 | 72 61 63 74 65 72 2e 20 |last cha|racter. |
|000063a0| 20 2a 2f 0a 20 20 20 20 | 69 66 20 28 2a 6e 65 78 | */. |if (*nex|
|000063b0| 74 63 68 61 72 20 3d 3d | 20 27 5c 30 27 29 0a 20 |tchar ==| '\0'). |
|000063c0| 20 20 20 20 20 2b 2b 6f | 70 74 69 6e 64 3b 0a 0a | ++o|ptind;..|
|000063d0| 20 20 20 20 69 66 20 28 | 74 65 6d 70 20 3d 3d 20 | if (|temp == |
|000063e0| 4e 55 4c 4c 20 7c 7c 20 | 63 20 3d 3d 20 27 3a 27 |NULL || |c == ':'|
|000063f0| 29 0a 20 20 20 20 20 20 | 7b 0a 09 69 66 20 28 6f |). |{..if (o|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.